From 40c670ad3033809ca996456c353998aa6cab672f Mon Sep 17 00:00:00 2001
From: Vadim <44135514+vodemn@users.noreply.github.com>
Date: Tue, 25 Jul 2023 17:31:01 +0200
Subject: [PATCH 1/5] Updated README Build section (#94)
* Update README.md
* Set exact Flutter version for workflows
* Added stub `DefaultFirebaseOptions`
* Fixed `rm`
* Removed `rm`
* Update .gitignore
* Added readable name to ci workflow
* Build -> Development
* Update ci.yml
---
.github/workflows/cd_dev.yml | 1 +
.github/workflows/cd_prod.yml | 1 +
.github/workflows/ci.yml | 30 ++++------------
README.md | 32 ++++++++++++++---
lib/firebase_options.dart | 68 +++++++++++++++++++++++++++++++++++
lib/main_prod.dart | 8 ++++-
6 files changed, 112 insertions(+), 28 deletions(-)
create mode 100644 lib/firebase_options.dart
diff --git a/.github/workflows/cd_dev.yml b/.github/workflows/cd_dev.yml
index d90d0fb..e0e6a25 100644
--- a/.github/workflows/cd_dev.yml
+++ b/.github/workflows/cd_dev.yml
@@ -71,6 +71,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: "stable"
+ flutter-version: '3.10.0'
- name: Prepare flutter project
run: |
diff --git a/.github/workflows/cd_prod.yml b/.github/workflows/cd_prod.yml
index 9ff3d6e..9e45644 100644
--- a/.github/workflows/cd_prod.yml
+++ b/.github/workflows/cd_prod.yml
@@ -73,6 +73,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: "stable"
+ flutter-version: '3.10.0'
- name: Prepare flutter project
run: |
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e8956f6..9022170 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -12,18 +12,12 @@ on:
branches: ["main"]
jobs:
- build:
+ analyze_and_test:
+ name: Analyze & test
runs-on: macos-11
timeout-minutes: 10
steps:
- - uses: shaunco/ssh-agent@git-repo-mapping
- with:
- ssh-private-key: |
- ${{ secrets.M3_LIGHTMETER_IAP_KEY }}
- repo-mappings: |
- github.com/vodemn/m3_lightmeter_iap
-
- uses: actions/checkout@v3
with:
submodules: recursive
@@ -31,23 +25,13 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: "stable"
+ flutter-version: '3.10.0'
- - name: Check flutter version
- run: flutter --version
-
- - name: Install dependencies
- run: flutter pub get
-
- - name: Generate intl
- run: flutter pub run intl_utils:generate
-
- - name: Restore firebase_options.dart
- env:
- FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
+ - name: Prepare flutter project
run: |
- FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
- echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
- cp $FIREBASE_OPTIONS_PATH ./lib
+ flutter --version
+ flutter pub get
+ flutter pub run intl_utils:generate
- name: Analyze project source
run: flutter analyze lib --fatal-infos
diff --git a/README.md b/README.md
index 0b4dae8..2fef498 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
- [Table of contents](#table-of-contents)
- [Backstory](#backstory)
- [Screenshots](#screenshots)
-- [Build](#build)
+- [Development](#development)
- [Contribution](#contribution)
- [iOS Limitations](#ios-limitations)
@@ -27,22 +27,46 @@ Without further delay behold my new Lightmeter app inspired by Material You (a.k
-# Build
+# Development
-As part of this project is private, you will be able to run this app from the _main_dev.dart_ file (i.e. --flavor dev). Also to avoid fatal errors the _main_prod.dart_ file is excluded from analysis.
+### 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).
+
+### 2. (Optional) Install Firebase
+
+Out of the box Firebase Crashlytics won't work. If you want to add Crashlytics to your local build please follow [this guide](https://firebase.google.com/docs/flutter/setup).
+
+### 3. Get packages
+
+Fetch all the neccessary dependencies and generate translation files by running the following commands:
+```console
+flutter pub get
+flutter pub run intl_utils:generate
+```
+
+### 4. Build
+
+You can build an apk by running the following command from the root of the repository:
+```console
+flutter build apk --release --flavor $FLAVOR --dart-define cameraPreviewAspectRatio=2/3 -t lib/main_$FLAVOR.dart
+```
+Just replace `$FLAVOR` with `dev` or `prod`.
# Contribution
To report a bug or suggest a new feature open a new [issue](https://github.com/vodemn/m3_lightmeter/issues).
-In case you want to help develop this project you need to follow this [style guide](doc/style_guide.md).
+In case you want to help develop this project feel free to open a Pull Request, but you need to follow this [style guide](doc/style_guide.md).
# iOS Limitations
A list of features, that Android version of the app has and that iOS does not.
## Incident light metering
+
Apple does not provide API for reading Lux stream form the ambient light sensor. Lux can be calculated based on front camera image stream, but this would be a reflected light. So there is no way incident light metering can be implemented on iOS.
## Volume buttons action
+
This can be [implemented](https://stackoverflow.com/questions/70161271/ios-override-hardware-volume-buttons-same-as-zello) but the app will be rejected due to [2.5.9](https://developer.apple.com/app-store/review/guidelines/#software-requirements)
\ No newline at end of file
diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart
new file mode 100644
index 0000000..a8a32c7
--- /dev/null
+++ b/lib/firebase_options.dart
@@ -0,0 +1,68 @@
+// File generated by FlutterFire CLI.
+// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
+import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
+import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;
+
+/// Default [FirebaseOptions] for use with your Firebase apps.
+///
+/// Example:
+/// ```dart
+/// import 'firebase_options.dart';
+/// // ...
+/// await Firebase.initializeApp(
+/// options: DefaultFirebaseOptions.currentPlatform,
+/// );
+/// ```
+class DefaultFirebaseOptions {
+ static FirebaseOptions get currentPlatform {
+ if (kIsWeb) {
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for web - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ }
+ switch (defaultTargetPlatform) {
+ case TargetPlatform.android:
+ return android;
+ case TargetPlatform.iOS:
+ return ios;
+ case TargetPlatform.macOS:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for macos - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ case TargetPlatform.windows:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for windows - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ case TargetPlatform.linux:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for linux - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ default:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions are not supported for this platform.',
+ );
+ }
+ }
+
+ static const FirebaseOptions android = FirebaseOptions(
+ apiKey: '',
+ appId: '',
+ messagingSenderId: '',
+ projectId: '',
+ storageBucket: '',
+ );
+
+ static const FirebaseOptions ios = FirebaseOptions(
+ apiKey: '',
+ appId: '',
+ messagingSenderId: '',
+ projectId: '',
+ storageBucket: '',
+ iosClientId: '',
+ iosBundleId: '',
+ );
+}
diff --git a/lib/main_prod.dart b/lib/main_prod.dart
index a47d421..fc1700a 100644
--- a/lib/main_prod.dart
+++ b/lib/main_prod.dart
@@ -1,3 +1,5 @@
+import 'dart:developer';
+
import 'package:flutter/material.dart';
import 'package:lightmeter/application.dart';
import 'package:lightmeter/environment.dart';
@@ -5,6 +7,10 @@ import 'package:lightmeter/firebase.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
- await initializeFirebase();
+ try {
+ await initializeFirebase();
+ } catch (e) {
+ log(e.toString());
+ }
runApp(const Application(Environment.prod()));
}
From 6a9036ce5eed82cd312334ff698411bb85be6333 Mon Sep 17 00:00:00 2001
From: Vadim
Date: Tue, 1 Aug 2023 12:58:43 +0200
Subject: [PATCH 2/5] Camera is taking too long to take a picture
---
.../components/camera_container/bloc_container_camera.dart | 1 +
pubspec.yaml | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
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 cafce13..fee9899 100644
--- a/lib/screens/metering/components/camera_container/bloc_container_camera.dart
+++ b/lib/screens/metering/components/camera_container/bloc_container_camera.dart
@@ -129,6 +129,7 @@ class CameraContainerBloc extends EvSourceBlocBase([
_cameraController!.getMinZoomLevel(),
diff --git a/pubspec.yaml b/pubspec.yaml
index 1f8ed64..0015829 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -9,7 +9,7 @@ environment:
dependencies:
app_settings: 4.2.0
bloc_concurrency: 0.2.2
- camera: 0.10.5
+ camera: 0.10.5+2
clipboard: 0.1.3
dynamic_color: 1.6.5
exif: 3.1.4
From 50c2460f16494b69fc60a9c2eea632ca2273cdd8 Mon Sep 17 00:00:00 2001
From: vodemn
Date: Tue, 1 Aug 2023 11:08:55 +0000
Subject: [PATCH 3/5] Version bump
---
pubspec.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pubspec.yaml b/pubspec.yaml
index 0015829..e2c7b6d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: lightmeter
description: A new Flutter project.
publish_to: "none"
-version: 0.12.2+33
+version: 0.12.3+34
environment:
sdk: ">=3.0.0 <4.0.0"
From c12cfb16976b69c19affc4f802852c936741f845 Mon Sep 17 00:00:00 2001
From: Vadim
Date: Thu, 3 Aug 2023 22:46:01 +0200
Subject: [PATCH 4/5] Lock & release focus when taking a picture
---
.../components/camera_container/bloc_container_camera.dart | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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 fee9899..9c8658d 100644
--- a/lib/screens/metering/components/camera_container/bloc_container_camera.dart
+++ b/lib/screens/metering/components/camera_container/bloc_container_camera.dart
@@ -129,7 +129,6 @@ class CameraContainerBloc extends EvSourceBlocBase([
_cameraController!.getMinZoomLevel(),
@@ -206,7 +205,13 @@ 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 Uint8List bytes = await file.readAsBytes();
Directory(file.path).deleteSync(recursive: true);
From 6e1aaf5acf0d707d6853048d07cda87a037457c2 Mon Sep 17 00:00:00 2001
From: vodemn
Date: Thu, 3 Aug 2023 20:54:33 +0000
Subject: [PATCH 5/5] Version bump
---
pubspec.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pubspec.yaml b/pubspec.yaml
index e2c7b6d..315e72f 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: lightmeter
description: A new Flutter project.
publish_to: "none"
-version: 0.12.3+34
+version: 0.12.4+35
environment:
sdk: ">=3.0.0 <4.0.0"