From bfd0bfe531efb264a8b0f2b5100ac16cd64d2993 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:14:37 +0200 Subject: [PATCH] ML-108 First exposure metering seems to be wrong (#163) * use latest `camera_android_camerax` * fixed trailing commas * moved ci/cd to 3.13.9 * removed focus & exposure fix * fixed camera not being initialized on Android * removed unused import --- .github/workflows/build_apk.yml | 2 +- .github/workflows/build_ipa.yml | 2 +- .github/workflows/pr_check.yml | 2 +- .github/workflows/run_integration_tests.yml | 2 +- README.md | 2 +- integration_test/mocks/iap_products_mock.dart | 2 +- .../models/metering_screen_layout_config.dart | 2 +- lib/firebase_options.dart | 1 - .../bloc_container_camera.dart | 33 ++++--------------- .../camera_preview/widget_camera_preview.dart | 2 +- .../widget_container_camera.dart | 2 +- .../widget_top_bar_metering.dart | 2 +- .../widget_container_reading_value.dart | 2 +- .../widget_dialog_calibration.dart | 2 +- .../screen_equipment_profile.dart | 2 +- .../dialog_filter/widget_dialog_filter.dart | 2 +- .../dialog_switch/widget_dialog_switch.dart | 2 +- pubspec.yaml | 7 ++-- test/providers/films_provider_test.dart | 2 +- .../user_preferences_provider_test.dart | 4 +-- .../equipment_profile_picker_test.dart | 2 +- .../readings_container/film_picker_test.dart | 2 +- .../utils/grant_camera_permission.dart | 2 +- 23 files changed, 31 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build_apk.yml b/.github/workflows/build_apk.yml index 3ea2ed2..03ceb46 100644 --- a/.github/workflows/build_apk.yml +++ b/.github/workflows/build_apk.yml @@ -113,7 +113,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: "stable" - flutter-version: "3.10.0" + flutter-version: "3.13.9" - name: Prepare flutter project run: | diff --git a/.github/workflows/build_ipa.yml b/.github/workflows/build_ipa.yml index 1bdaef9..602dd9e 100644 --- a/.github/workflows/build_ipa.yml +++ b/.github/workflows/build_ipa.yml @@ -108,7 +108,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: "stable" - flutter-version: "3.10.0" + flutter-version: "3.13.9" - name: Prepare flutter project run: | diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml index b2153eb..75ef37e 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr_check.yml @@ -42,7 +42,7 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: "stable" - flutter-version: "3.10.0" + flutter-version: "3.13.9" - name: Prepare flutter project run: | diff --git a/.github/workflows/run_integration_tests.yml b/.github/workflows/run_integration_tests.yml index c378b4b..a246798 100644 --- a/.github/workflows/run_integration_tests.yml +++ b/.github/workflows/run_integration_tests.yml @@ -31,7 +31,7 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: "stable" - flutter-version: "3.10.0" + flutter-version: "3.13.9" - name: Prepare app run: | diff --git a/README.md b/README.md index 1162d4c..f3a57d1 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Without further delay behold my new Lightmeter app inspired by Material You (a.k ### 1. Install Flutter -To build this app you need to install Flutter 3.10.0 stable. [How to install](https://docs.flutter.dev/get-started/install). +To build this app you need to install Flutter 3.13.9 stable. [How to install](https://docs.flutter.dev/get-started/install). ### 2. Project setup diff --git a/integration_test/mocks/iap_products_mock.dart b/integration_test/mocks/iap_products_mock.dart index 1a67c69..1a79bc2 100644 --- a/integration_test/mocks/iap_products_mock.dart +++ b/integration_test/mocks/iap_products_mock.dart @@ -27,7 +27,7 @@ class MockIAPProductsProviderState extends State { IAPProduct( storeId: IAPProductType.paidFeatures.storeId, status: _purchased ? IAPProductStatus.purchased : IAPProductStatus.purchasable, - ) + ), ]), child: widget.child, ); diff --git a/lib/data/models/metering_screen_layout_config.dart b/lib/data/models/metering_screen_layout_config.dart index 7d550e4..a558202 100644 --- a/lib/data/models/metering_screen_layout_config.dart +++ b/lib/data/models/metering_screen_layout_config.dart @@ -23,7 +23,7 @@ extension MeteringScreenLayoutConfigJson on MeteringScreenLayoutConfig { return { for (final f in MeteringScreenLayoutFeature.values) - f: (data[migratedIndex(f).toString()] ?? data[f.name]) as bool? ?? true + f: (data[migratedIndex(f).toString()] ?? data[f.name]) as bool? ?? true, }; } diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart index a8a32c7..befdbed 100644 --- a/lib/firebase_options.dart +++ b/lib/firebase_options.dart @@ -50,7 +50,6 @@ class DefaultFirebaseOptions { static const FirebaseOptions android = FirebaseOptions( apiKey: '', - appId: '', messagingSenderId: '', projectId: '', storageBucket: '', diff --git a/lib/screens/metering/components/camera_container/bloc_container_camera.dart b/lib/screens/metering/components/camera_container/bloc_container_camera.dart index ce62fd1..56dec48 100644 --- a/lib/screens/metering/components/camera_container/bloc_container_camera.dart +++ b/lib/screens/metering/components/camera_container/bloc_container_camera.dart @@ -4,7 +4,6 @@ import 'dart:io'; import 'dart:math' as math; import 'package:camera/camera.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -217,15 +216,9 @@ class CameraContainerBloc extends EvSourceBlocBase _takePhoto() async { try { - // https://github.com/flutter/flutter/issues/84957#issuecomment-1661155095 - await _cameraController!.setFocusMode(FocusMode.locked); - await _cameraController!.setExposureMode(ExposureMode.locked); final file = await _cameraController!.takePicture(); - await _cameraController!.setFocusMode(FocusMode.auto); - await _cameraController!.setExposureMode(ExposureMode.auto); final bytes = await file.readAsBytes(); Directory(file.path).deleteSync(recursive: true); - return await evFromImage(bytes); } catch (e, stackTrace) { _analytics.logCrash(e, stackTrace); @@ -257,26 +250,12 @@ class _WidgetsBindingObserver with WidgetsBindingObserver { /// Revoking camera permissions results in app being killed both on Android and iOS @override void didChangeAppLifecycleState(AppLifecycleState state) { - switch (defaultTargetPlatform) { - /// On Android opening a dialog results in [AppLifecycleState.inactive] - case TargetPlatform.android: - if (_prevState == AppLifecycleState.inactive && state == AppLifecycleState.resumed) { - return; - } - _prevState = state; - onLifecycleStateChanged(state); - - /// When coming from the app's settings iOS fires paused -> inactive -> resumed state which falls into this condition. - /// So the inactive state is skipped. - case TargetPlatform.iOS: - if (state == AppLifecycleState.inactive) { - return; - } - if (_prevState != state) { - _prevState = state; - onLifecycleStateChanged(state); - } - default: + if (state == AppLifecycleState.inactive) { + return; + } + if (_prevState != state) { + _prevState = state; + onLifecycleStateChanged(state); } } } diff --git a/lib/screens/metering/components/camera_container/components/camera_preview/widget_camera_preview.dart b/lib/screens/metering/components/camera_container/components/camera_preview/widget_camera_preview.dart index 0164a35..fe61bed 100644 --- a/lib/screens/metering/components/camera_container/components/camera_preview/widget_camera_preview.dart +++ b/lib/screens/metering/components/camera_container/components/camera_preview/widget_camera_preview.dart @@ -117,7 +117,7 @@ class _CameraPreviewBuilderState extends State<_CameraPreviewBuilder> { context, CameraFeature.spotMetering, )) - CameraSpotDetector(onSpotTap: widget.onSpotTap) + CameraSpotDetector(onSpotTap: widget.onSpotTap), ], ], ) diff --git a/lib/screens/metering/components/camera_container/widget_container_camera.dart b/lib/screens/metering/components/camera_container/widget_container_camera.dart index 3e81d48..ceaca91 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -97,7 +97,7 @@ class CameraContainer extends StatelessWidget { ), ], ), - ) + ), ], ); } diff --git a/lib/screens/metering/components/shared/metering_top_bar/widget_top_bar_metering.dart b/lib/screens/metering/components/shared/metering_top_bar/widget_top_bar_metering.dart index a005b85..f1fef15 100644 --- a/lib/screens/metering/components/shared/metering_top_bar/widget_top_bar_metering.dart +++ b/lib/screens/metering/components/shared/metering_top_bar/widget_top_bar_metering.dart @@ -42,7 +42,7 @@ class MeteringTopBar extends StatelessWidget { child: preview, ), ), - ] + ], ], ), ), diff --git a/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart b/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart index 6968db6..0abc0f4 100644 --- a/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart +++ b/lib/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart @@ -92,7 +92,7 @@ class _ReadingValueBuilder extends StatelessWidget { overflow: TextOverflow.ellipsis, softWrap: false, ), - ) + ), ], ); } diff --git a/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart b/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart index 56c4ed0..57b1316 100644 --- a/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart +++ b/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart @@ -120,7 +120,7 @@ class _CalibrationUnit extends StatelessWidget { tooltip: S.of(context).tooltipResetToZero, ), ], - ) + ), ], ); } diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart index 6879a2c..9f3cf5a 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart @@ -41,7 +41,7 @@ class _EquipmentProfilesScreenState extends State { SliverFillRemaining( hasScrollBody: false, child: _EquipmentProfilesListPlaceholder(onTap: _addProfile), - ) + ), ] : [ SliverList( diff --git a/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart b/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart index eb03e23..374c8d7 100644 --- a/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart +++ b/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart @@ -135,7 +135,7 @@ class _DialogFilterState extends State> { ), ], ), - ) + ), ], ), ), diff --git a/lib/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart b/lib/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart index fdf7cc5..dc43017 100644 --- a/lib/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart +++ b/lib/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart @@ -51,7 +51,7 @@ class _DialogSwitchState extends State> { padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingL), child: Text(widget.description!), ), - const SizedBox(height: Dimens.grid16) + const SizedBox(height: Dimens.grid16), ], ListView( shrinkWrap: true, diff --git a/pubspec.yaml b/pubspec.yaml index 56bac35..cc4eb2a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: app_settings: 4.2.0 bloc_concurrency: 0.2.2 camera: 0.10.5+2 + camera_android_camerax: 0.6.1+1 clipboard: 0.1.3 dynamic_color: 1.6.6 exif: 3.1.4 @@ -22,7 +23,7 @@ dependencies: flutter_bloc: 8.1.3 flutter_localizations: sdk: flutter - intl: 0.18.0 + intl: 0.18.1 intl_utils: 2.8.2 light_sensor: 3.0.0 m3_lightmeter_iap: @@ -33,7 +34,7 @@ dependencies: git: url: "https://github.com/vodemn/m3_lightmeter_resources" ref: main - material_color_utilities: 0.2.0 + material_color_utilities: 0.5.0 package_info_plus: 4.0.2 permission_handler: 10.4.3 platform: 3.1.0 @@ -54,7 +55,7 @@ dev_dependencies: lint: 2.1.2 meta: 1.9.1 mocktail: 0.3.0 - test: 1.24.1 + test: 1.24.3 flutter: uses-material-design: true diff --git a/test/providers/films_provider_test.dart b/test/providers/films_provider_test.dart index 760ca43..47c35c1 100644 --- a/test/providers/films_provider_test.dart +++ b/test/providers/films_provider_test.dart @@ -26,7 +26,7 @@ void main() { IAPProduct( storeId: IAPProductType.paidFeatures.storeId, status: productStatus, - ) + ), ], child: FilmsProvider( storageService: mockIAPStorageService, diff --git a/test/providers/user_preferences_provider_test.dart b/test/providers/user_preferences_provider_test.dart index 1a91419..3ea3fc3 100644 --- a/test/providers/user_preferences_provider_test.dart +++ b/test/providers/user_preferences_provider_test.dart @@ -317,7 +317,7 @@ void main() { onPressed: () => UserPreferencesProvider.of(context).setThemeType(ThemeType.dark), child: Text('${UserPreferencesProvider.themeTypeOf(context)}'), ), - Text('${Theme.of(context).colorScheme.brightness}') + Text('${Theme.of(context).colorScheme.brightness}'), ], ), ); @@ -344,7 +344,7 @@ void main() { onPressed: () => UserPreferencesProvider.of(context).setThemeType(ThemeType.systemDefault), child: Text('${UserPreferencesProvider.themeTypeOf(context)}'), ), - Text('${Theme.of(context).colorScheme.brightness}') + Text('${Theme.of(context).colorScheme.brightness}'), ], ), ); diff --git a/test/screens/metering/components/shared/readings_container/equipment_profile_picker_test.dart b/test/screens/metering/components/shared/readings_container/equipment_profile_picker_test.dart index 6853168..731ce4e 100644 --- a/test/screens/metering/components/shared/readings_container/equipment_profile_picker_test.dart +++ b/test/screens/metering/components/shared/readings_container/equipment_profile_picker_test.dart @@ -28,7 +28,7 @@ void main() { IAPProduct( storeId: IAPProductType.paidFeatures.storeId, status: IAPProductStatus.purchased, - ) + ), ], child: EquipmentProfileProvider( storageService: mockIAPStorageService, diff --git a/test/screens/metering/components/shared/readings_container/film_picker_test.dart b/test/screens/metering/components/shared/readings_container/film_picker_test.dart index 19f4840..03f50ed 100644 --- a/test/screens/metering/components/shared/readings_container/film_picker_test.dart +++ b/test/screens/metering/components/shared/readings_container/film_picker_test.dart @@ -27,7 +27,7 @@ void main() { IAPProduct( storeId: IAPProductType.paidFeatures.storeId, status: IAPProductStatus.purchased, - ) + ), ], child: FilmsProvider( storageService: mockIAPStorageService, diff --git a/test_driver/utils/grant_camera_permission.dart b/test_driver/utils/grant_camera_permission.dart index c6f56d7..06c6607 100644 --- a/test_driver/utils/grant_camera_permission.dart +++ b/test_driver/utils/grant_camera_permission.dart @@ -26,7 +26,7 @@ Future grantCameraPermission() async { 'pm', 'grant', 'com.vodemn.lightmeter.dev', - 'android.permission.CAMERA' + 'android.permission.CAMERA', ]); } catch (e) { log('Error occured: $e');