mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-07-07 06:30:42 +00:00
Merge f697248d0c
into f820f9fbba
This commit is contained in:
commit
602ba99b74
36 changed files with 490 additions and 222 deletions
|
@ -2,20 +2,17 @@ package com.vodemn.lightmeter
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.WindowManager
|
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
|
import com.vodemn.lightmeter.PlatformChannels.CaffeinePlatformChannel
|
||||||
|
import com.vodemn.lightmeter.PlatformChannels.CameraInfoPlatformChannel
|
||||||
|
import com.vodemn.lightmeter.PlatformChannels.VolumePlatformChannel
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
import io.flutter.plugin.common.EventChannel
|
|
||||||
import io.flutter.plugin.common.EventChannel.EventSink
|
|
||||||
import io.flutter.plugin.common.MethodChannel
|
|
||||||
|
|
||||||
class MainActivity : FlutterActivity() {
|
class MainActivity : FlutterActivity() {
|
||||||
private lateinit var keepScreenOnChannel: MethodChannel
|
private val caffeinePlatformChannel = CaffeinePlatformChannel()
|
||||||
private lateinit var volumeHandlingChannel: MethodChannel
|
private val cameraInfoPlatformChannel = CameraInfoPlatformChannel()
|
||||||
private lateinit var volumeEventChannel: EventChannel
|
private val volumePlatformChannel = VolumePlatformChannel()
|
||||||
private var volumeEventsEmitter: EventSink? = null
|
|
||||||
private var handleVolume = false
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -24,72 +21,24 @@ class MainActivity : FlutterActivity() {
|
||||||
|
|
||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
super.configureFlutterEngine(flutterEngine)
|
super.configureFlutterEngine(flutterEngine)
|
||||||
keepScreenOnChannel = MethodChannel(
|
val binaryMessenger = flutterEngine.dartExecutor.binaryMessenger
|
||||||
flutterEngine.dartExecutor.binaryMessenger,
|
caffeinePlatformChannel.onAttachedToEngine(binaryMessenger, window)
|
||||||
"com.vodemn.lightmeter/keepScreenOn"
|
cameraInfoPlatformChannel.onAttachedToEngine(binaryMessenger, context)
|
||||||
)
|
volumePlatformChannel.onAttachedToEngine(binaryMessenger)
|
||||||
keepScreenOnChannel.setMethodCallHandler { call, result ->
|
|
||||||
when (call.method) {
|
|
||||||
"isKeepScreenOn" -> result.success((window.attributes.flags and WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0)
|
|
||||||
"setKeepScreenOn" -> {
|
|
||||||
if (call.arguments !is Boolean) {
|
|
||||||
result.error("invalid args", "Argument should be of type Bool for 'setKeepScreenOn' call", null)
|
|
||||||
} else {
|
|
||||||
if (call.arguments as Boolean) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
||||||
else window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
volumeHandlingChannel = MethodChannel(
|
|
||||||
flutterEngine.dartExecutor.binaryMessenger,
|
|
||||||
"com.vodemn.lightmeter/volumeHandling"
|
|
||||||
)
|
|
||||||
volumeHandlingChannel.setMethodCallHandler { call, result ->
|
|
||||||
when (call.method) {
|
|
||||||
"setVolumeHandling" -> {
|
|
||||||
handleVolume = call.arguments as Boolean
|
|
||||||
result.success(handleVolume)
|
|
||||||
}
|
|
||||||
else -> result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
volumeEventChannel = EventChannel(
|
|
||||||
flutterEngine.dartExecutor.binaryMessenger,
|
|
||||||
"com.vodemn.lightmeter/volumeEvents"
|
|
||||||
)
|
|
||||||
volumeEventChannel.setStreamHandler(object : EventChannel.StreamHandler {
|
|
||||||
override fun onListen(listener: Any?, eventSink: EventSink) {
|
|
||||||
volumeEventsEmitter = eventSink
|
|
||||||
}
|
|
||||||
override fun onCancel(listener: Any?) {
|
|
||||||
volumeEventsEmitter = null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
keepScreenOnChannel.setMethodCallHandler(null)
|
caffeinePlatformChannel.onDestroy()
|
||||||
volumeHandlingChannel.setMethodCallHandler(null)
|
cameraInfoPlatformChannel.onDestroy()
|
||||||
volumeEventChannel.setStreamHandler(null)
|
volumePlatformChannel.onDestroy()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onKeyDown(code: Int, event: KeyEvent): Boolean {
|
override fun onKeyDown(code: Int, event: KeyEvent): Boolean {
|
||||||
return when (val keyCode: Int = event.keyCode) {
|
return if (volumePlatformChannel.onKeyDown(code, event)) {
|
||||||
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
|
||||||
if (handleVolume) {
|
|
||||||
volumeEventsEmitter?.success(keyCode)
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
super.onKeyDown(code, event)
|
super.onKeyDown(code, event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> super.onKeyDown(code, event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.vodemn.lightmeter.PlatformChannels
|
||||||
|
|
||||||
|
import android.view.Window
|
||||||
|
import android.view.WindowManager
|
||||||
|
import io.flutter.plugin.common.BinaryMessenger
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
|
||||||
|
/** CaffeinePlatformChannel */
|
||||||
|
class CaffeinePlatformChannel {
|
||||||
|
private lateinit var channel: MethodChannel
|
||||||
|
|
||||||
|
fun onAttachedToEngine(binaryMessenger: BinaryMessenger, window: Window) {
|
||||||
|
channel = MethodChannel(
|
||||||
|
binaryMessenger,
|
||||||
|
"com.vodemn.lightmeter.CaffeinePlatformChannel.MethodChannel"
|
||||||
|
)
|
||||||
|
channel.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"isKeepScreenOn" -> result.success((window.attributes.flags and WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0)
|
||||||
|
"setKeepScreenOn" -> {
|
||||||
|
if (call.arguments !is Boolean) {
|
||||||
|
result.error(
|
||||||
|
"invalid args",
|
||||||
|
"Argument should be of type Bool for 'setKeepScreenOn' call",
|
||||||
|
null
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
if (call.arguments as Boolean) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
else window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onDestroy() {
|
||||||
|
channel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.vodemn.lightmeter.PlatformChannels
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.hardware.camera2.CameraCharacteristics
|
||||||
|
import android.hardware.camera2.CameraManager
|
||||||
|
import android.hardware.camera2.CameraMetadata.LENS_FACING_BACK
|
||||||
|
import io.flutter.plugin.common.BinaryMessenger
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import kotlin.math.pow
|
||||||
|
import kotlin.math.sqrt
|
||||||
|
|
||||||
|
/** CameraInfoPlatformChannel */
|
||||||
|
class CameraInfoPlatformChannel {
|
||||||
|
private lateinit var channel: MethodChannel
|
||||||
|
private lateinit var cameraManager: CameraManager
|
||||||
|
private var mainCameraEfl: Double? = null
|
||||||
|
|
||||||
|
fun onAttachedToEngine(binaryMessenger: BinaryMessenger, context: Context) {
|
||||||
|
channel = MethodChannel(
|
||||||
|
binaryMessenger,
|
||||||
|
"com.vodemn.lightmeter.CameraInfoPlatformChannel.MethodChannel"
|
||||||
|
)
|
||||||
|
cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
|
||||||
|
channel.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"mainCameraEfl" -> {
|
||||||
|
mainCameraEfl = mainCameraEfl ?: getMainCameraFocalLength35mm()
|
||||||
|
result.success(mainCameraEfl)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onDestroy() {
|
||||||
|
channel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getMainCameraFocalLength35mm(): Double? {
|
||||||
|
return cameraManager.cameraIdList.map {
|
||||||
|
cameraManager.getCameraCharacteristics(it)
|
||||||
|
}.first {
|
||||||
|
it.get(CameraCharacteristics.LENS_FACING) == LENS_FACING_BACK
|
||||||
|
}.focalLength35mm()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun CameraCharacteristics.focalLength35mm(): Double? {
|
||||||
|
val defaultFocalLength =
|
||||||
|
get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS)?.first()
|
||||||
|
val sensorSize = get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE)
|
||||||
|
return if (defaultFocalLength != null && sensorSize != null) {
|
||||||
|
// https://en.wikipedia.org/wiki/35_mm_equivalent_focal_length#Conversions
|
||||||
|
43.27 * defaultFocalLength / sqrt(sensorSize.height.pow(2) + sensorSize.width.pow(2))
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.vodemn.lightmeter.PlatformChannels
|
||||||
|
|
||||||
|
import android.view.KeyEvent
|
||||||
|
import io.flutter.plugin.common.BinaryMessenger
|
||||||
|
import io.flutter.plugin.common.EventChannel
|
||||||
|
import io.flutter.plugin.common.EventChannel.EventSink
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
|
||||||
|
/** VolumePlatformChannel */
|
||||||
|
class VolumePlatformChannel {
|
||||||
|
private lateinit var volumeMethodChannel: MethodChannel
|
||||||
|
private lateinit var volumeEventChannel: EventChannel
|
||||||
|
private var volumeEventsEmitter: EventSink? = null
|
||||||
|
private var handleVolume = false
|
||||||
|
|
||||||
|
fun onAttachedToEngine(binaryMessenger: BinaryMessenger) {
|
||||||
|
volumeMethodChannel = MethodChannel(
|
||||||
|
binaryMessenger,
|
||||||
|
"com.vodemn.lightmeter.VolumePlatformChannel.MethodChannel"
|
||||||
|
)
|
||||||
|
volumeMethodChannel.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"setVolumeHandling" -> {
|
||||||
|
handleVolume = call.arguments as Boolean
|
||||||
|
result.success(handleVolume)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volumeEventChannel = EventChannel(
|
||||||
|
binaryMessenger,
|
||||||
|
"com.vodemn.lightmeter.VolumePlatformChannel.EventChannel"
|
||||||
|
)
|
||||||
|
volumeEventChannel.setStreamHandler(object : EventChannel.StreamHandler {
|
||||||
|
override fun onListen(listener: Any?, eventSink: EventSink) {
|
||||||
|
volumeEventsEmitter = eventSink
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCancel(listener: Any?) {
|
||||||
|
volumeEventsEmitter = null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onDestroy() {
|
||||||
|
volumeMethodChannel.setMethodCallHandler(null)
|
||||||
|
volumeEventChannel.setStreamHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onKeyDown(code: Int, event: KeyEvent): Boolean {
|
||||||
|
return when (val keyCode: Int = event.keyCode) {
|
||||||
|
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||||
|
if (handleVolume) {
|
||||||
|
volumeEventsEmitter?.success(keyCode)
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -305,7 +305,8 @@ Future<void> _expectMeteringState(
|
||||||
await tester.scrollToTheLastExposurePair(equipmentProfile: equipmentProfile);
|
await tester.scrollToTheLastExposurePair(equipmentProfile: equipmentProfile);
|
||||||
expectExposurePairsListItem(tester, slowest.split(' - ')[0], slowest.split(' - ')[1]);
|
expectExposurePairsListItem(tester, slowest.split(' - ')[0], slowest.split(' - ')[1]);
|
||||||
expectMeasureButton(ev);
|
expectMeasureButton(ev);
|
||||||
expect(find.text(equipmentProfile.lensZoom.toZoom()), findsOneWidget);
|
final BuildContext context = tester.element(find.byType(IsoValuePicker));
|
||||||
|
expect(find.text(equipmentProfile.lensZoom.toZoom(context)), findsOneWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _expectMeteringStateAndMeasure(
|
Future<void> _expectMeteringStateAndMeasure(
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
001BDA042DD1252B00122957 /* CameraInfoPlatformChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 001BDA022DD0BBA700122957 /* CameraInfoPlatformChannel.swift */; };
|
||||||
|
0035E99F2DD0B07C0053508B /* CaffeinePlatformChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0035E99E2DD0B0700053508B /* CaffeinePlatformChannel.swift */; };
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
5A1AF02F1E4619A6E479AA8B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C991C89D5763E562E77E475E /* Pods_Runner.framework */; };
|
5A1AF02F1E4619A6E479AA8B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C991C89D5763E562E77E475E /* Pods_Runner.framework */; };
|
||||||
|
@ -31,6 +33,8 @@
|
||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
001BDA022DD0BBA700122957 /* CameraInfoPlatformChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraInfoPlatformChannel.swift; sourceTree = "<group>"; };
|
||||||
|
0035E99E2DD0B0700053508B /* CaffeinePlatformChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaffeinePlatformChannel.swift; sourceTree = "<group>"; };
|
||||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||||
2913B1E428DD3F7921E898BC /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
|
2913B1E428DD3F7921E898BC /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
|
||||||
|
@ -69,6 +73,15 @@
|
||||||
/* End PBXFrameworksBuildPhase section */
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
/* Begin PBXGroup section */
|
||||||
|
0035E99D2DD0B05F0053508B /* PlatformChannels */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
0035E99E2DD0B0700053508B /* CaffeinePlatformChannel.swift */,
|
||||||
|
001BDA022DD0BBA700122957 /* CameraInfoPlatformChannel.swift */,
|
||||||
|
);
|
||||||
|
path = PlatformChannels;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
@ -110,6 +123,7 @@
|
||||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||||
|
0035E99D2DD0B05F0053508B /* PlatformChannels */,
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||||
);
|
);
|
||||||
path = Runner;
|
path = Runner;
|
||||||
|
@ -156,7 +170,7 @@
|
||||||
45F53C083F2EA48EF231DA16 /* [CP] Embed Pods Frameworks */,
|
45F53C083F2EA48EF231DA16 /* [CP] Embed Pods Frameworks */,
|
||||||
FF00F85CE432774850A0EDB7 /* [firebase_crashlytics] Crashlytics Upload Symbols */,
|
FF00F85CE432774850A0EDB7 /* [firebase_crashlytics] Crashlytics Upload Symbols */,
|
||||||
08127035D2CDEEEBA66FCDBB /* [CP] Copy Pods Resources */,
|
08127035D2CDEEEBA66FCDBB /* [CP] Copy Pods Resources */,
|
||||||
051083B0AECD5071E5FA2A6F /* FlutterFire: "flutterfire upload-crashlytics-symbols" */,
|
58ED09C740BAF94D922BAC2C /* FlutterFire: "flutterfire upload-crashlytics-symbols" */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
|
@ -216,24 +230,6 @@
|
||||||
/* End PBXResourcesBuildPhase section */
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXShellScriptBuildPhase section */
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
051083B0AECD5071E5FA2A6F /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = {
|
|
||||||
isa = PBXShellScriptBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
inputFileListPaths = (
|
|
||||||
);
|
|
||||||
inputPaths = (
|
|
||||||
);
|
|
||||||
name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\"";
|
|
||||||
outputFileListPaths = (
|
|
||||||
);
|
|
||||||
outputPaths = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
shellPath = /bin/sh;
|
|
||||||
shellScript = "\n#!/bin/bash\nPATH=\"${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\"\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=\"$PODS_ROOT/FirebaseCrashlytics/upload-symbols\" --platform=ios --apple-project-path=\"${SRCROOT}\" --env-platform-name=\"${PLATFORM_NAME}\" --env-configuration=\"${CONFIGURATION}\" --env-project-dir=\"${PROJECT_DIR}\" --env-built-products-dir=\"${BUILT_PRODUCTS_DIR}\" --env-dwarf-dsym-folder-path=\"${DWARF_DSYM_FOLDER_PATH}\" --env-dwarf-dsym-file-name=\"${DWARF_DSYM_FILE_NAME}\" --env-infoplist-path=\"${INFOPLIST_PATH}\" --default-config=default\n";
|
|
||||||
};
|
|
||||||
08127035D2CDEEEBA66FCDBB /* [CP] Copy Pods Resources */ = {
|
08127035D2CDEEEBA66FCDBB /* [CP] Copy Pods Resources */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
|
@ -306,6 +302,24 @@
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||||
showEnvVarsInLog = 0;
|
showEnvVarsInLog = 0;
|
||||||
};
|
};
|
||||||
|
58ED09C740BAF94D922BAC2C /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 8;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\"";
|
||||||
|
outputFileListPaths = (
|
||||||
|
);
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 1;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\n#!/bin/bash\nPATH=\"${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\"\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=\"$PODS_ROOT/FirebaseCrashlytics/upload-symbols\" --platform=ios --apple-project-path=\"${SRCROOT}\" --env-platform-name=\"${PLATFORM_NAME}\" --env-configuration=\"${CONFIGURATION}\" --env-project-dir=\"${PROJECT_DIR}\" --env-built-products-dir=\"${BUILT_PRODUCTS_DIR}\" --env-dwarf-dsym-folder-path=\"${DWARF_DSYM_FOLDER_PATH}\" --env-dwarf-dsym-file-name=\"${DWARF_DSYM_FILE_NAME}\" --env-infoplist-path=\"${INFOPLIST_PATH}\" --default-config=default\n";
|
||||||
|
};
|
||||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
alwaysOutOfDate = 1;
|
alwaysOutOfDate = 1;
|
||||||
|
@ -319,7 +333,7 @@
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
|
||||||
};
|
};
|
||||||
FF00F85CE432774850A0EDB7 /* [firebase_crashlytics] Crashlytics Upload Symbols */ = {
|
FF00F85CE432774850A0EDB7 /* [firebase_crashlytics] Crashlytics Upload Symbols */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
@ -352,6 +366,8 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||||
|
001BDA042DD1252B00122957 /* CameraInfoPlatformChannel.swift in Sources */,
|
||||||
|
0035E99F2DD0B07C0053508B /* CaffeinePlatformChannel.swift in Sources */,
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -603,11 +619,9 @@
|
||||||
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
|
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CODE_SIGN_STYLE = Manual;
|
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = 489Z6UQMGN;
|
||||||
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 489Z6UQMGN;
|
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
INFOPLIST_FILE = Runner/Info.plist;
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = Lightmeter;
|
INFOPLIST_KEY_CFBundleDisplayName = Lightmeter;
|
||||||
|
@ -619,7 +633,6 @@
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.vodemn.lightmeter;
|
PRODUCT_BUNDLE_IDENTIFIER = com.vodemn.lightmeter;
|
||||||
PRODUCT_NAME = Lightmeter;
|
PRODUCT_NAME = Lightmeter;
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Lightmeter Distribution";
|
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
|
|
@ -8,25 +8,8 @@ import Flutter
|
||||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||||
) -> Bool {
|
) -> Bool {
|
||||||
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
|
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
|
||||||
let keepScreenOnChannel = FlutterMethodChannel(name: "com.vodemn.lightmeter/keepScreenOn",
|
let caffeinePlatformChannel = CaffeinePlatformChannel(binaryMessenger: controller.binaryMessenger)
|
||||||
binaryMessenger: controller.binaryMessenger)
|
let cameraInfoPlatformChannel = CameraInfoPlatformChannel(binaryMessenger: controller.binaryMessenger)
|
||||||
keepScreenOnChannel.setMethodCallHandler({
|
|
||||||
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
|
||||||
switch call.method {
|
|
||||||
case "isKeepScreenOn":
|
|
||||||
result(UIApplication.shared.isIdleTimerDisabled)
|
|
||||||
case "setKeepScreenOn":
|
|
||||||
guard let keepOn = call.arguments as? Bool else {
|
|
||||||
result(FlutterError(code: "invalid arguments", message: "Argument should be of type Bool for 'setKeepScreenOn' call", details: nil))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
UIApplication.shared.isIdleTimerDisabled = keepOn
|
|
||||||
result(true)
|
|
||||||
default:
|
|
||||||
result(FlutterMethodNotImplemented)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
GeneratedPluginRegistrant.register(with: self)
|
GeneratedPluginRegistrant.register(with: self)
|
||||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||||
}
|
}
|
||||||
|
|
35
ios/Runner/PlatformChannels/CaffeinePlatformChannel.swift
Normal file
35
ios/Runner/PlatformChannels/CaffeinePlatformChannel.swift
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
//
|
||||||
|
// CaffeinePlatformChannel.swift
|
||||||
|
// Runner
|
||||||
|
//
|
||||||
|
// Created by Vadim Turko on 2025-05-11.
|
||||||
|
//
|
||||||
|
import Flutter
|
||||||
|
|
||||||
|
public class CaffeinePlatformChannel: NSObject {
|
||||||
|
let methodChannel: FlutterMethodChannel
|
||||||
|
|
||||||
|
init(binaryMessenger: FlutterBinaryMessenger) {
|
||||||
|
self.methodChannel = FlutterMethodChannel(
|
||||||
|
name: "com.vodemn.lightmeter.CaffeinePlatformChannel.MethodChannel",
|
||||||
|
binaryMessenger: binaryMessenger
|
||||||
|
)
|
||||||
|
super.init()
|
||||||
|
methodChannel.setMethodCallHandler({
|
||||||
|
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
||||||
|
switch call.method {
|
||||||
|
case "isKeepScreenOn":
|
||||||
|
result(UIApplication.shared.isIdleTimerDisabled)
|
||||||
|
case "setKeepScreenOn":
|
||||||
|
guard let keepOn = call.arguments as? Bool else {
|
||||||
|
result(FlutterError(code: "invalid arguments", message: "Argument should be of type Bool for 'setKeepScreenOn' call", details: nil))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
UIApplication.shared.isIdleTimerDisabled = keepOn
|
||||||
|
result(true)
|
||||||
|
default:
|
||||||
|
result(FlutterMethodNotImplemented)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
45
ios/Runner/PlatformChannels/CameraInfoPlatformChannel.swift
Normal file
45
ios/Runner/PlatformChannels/CameraInfoPlatformChannel.swift
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
//
|
||||||
|
// CameraInfoPlatformChannel.swift
|
||||||
|
// Runner
|
||||||
|
//
|
||||||
|
// Created by Vadim Turko on 2025-05-11.
|
||||||
|
//
|
||||||
|
import AVFoundation
|
||||||
|
import Flutter
|
||||||
|
|
||||||
|
public class CameraInfoPlatformChannel: NSObject {
|
||||||
|
let methodChannel: FlutterMethodChannel
|
||||||
|
|
||||||
|
init(binaryMessenger: FlutterBinaryMessenger) {
|
||||||
|
self.methodChannel = FlutterMethodChannel(
|
||||||
|
name: "com.vodemn.lightmeter.CameraInfoPlatformChannel.MethodChannel",
|
||||||
|
binaryMessenger: binaryMessenger
|
||||||
|
)
|
||||||
|
super.init()
|
||||||
|
methodChannel.setMethodCallHandler({
|
||||||
|
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
||||||
|
switch call.method {
|
||||||
|
case "mainCameraEfl":
|
||||||
|
if let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) {
|
||||||
|
result(self.get35mmEquivalentFocalLength(format: device.activeFormat))
|
||||||
|
} else {
|
||||||
|
result(nil)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
result(FlutterMethodNotImplemented)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func get35mmEquivalentFocalLength(format : AVCaptureDevice.Format) -> Float {
|
||||||
|
// get reported field of view. Documentation says this is the horizontal field of view
|
||||||
|
var fov = format.videoFieldOfView
|
||||||
|
// convert to radians
|
||||||
|
fov *= Float.pi/180.0
|
||||||
|
// angle and opposite of right angle triangle are half the fov and half the width of
|
||||||
|
// 35mm film (ie 18mm). The adjacent value of the right angle triangle is the equivalent
|
||||||
|
// focal length. Using some right angle triangle math you can work out focal length
|
||||||
|
let focalLen = 18 / tan(fov/2)
|
||||||
|
return focalLen
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||||
import 'package:lightmeter/data/analytics/analytics.dart';
|
import 'package:lightmeter/data/analytics/analytics.dart';
|
||||||
import 'package:lightmeter/data/analytics/api/analytics_firebase.dart';
|
import 'package:lightmeter/data/analytics/api/analytics_firebase.dart';
|
||||||
import 'package:lightmeter/data/caffeine_service.dart';
|
import 'package:lightmeter/data/caffeine_service.dart';
|
||||||
|
import 'package:lightmeter/data/camera_info_service.dart';
|
||||||
import 'package:lightmeter/data/haptics_service.dart';
|
import 'package:lightmeter/data/haptics_service.dart';
|
||||||
import 'package:lightmeter/data/light_sensor_service.dart';
|
import 'package:lightmeter/data/light_sensor_service.dart';
|
||||||
import 'package:lightmeter/data/permissions_service.dart';
|
import 'package:lightmeter/data/permissions_service.dart';
|
||||||
|
@ -99,11 +100,13 @@ class _ApplicationWrapperState extends State<ApplicationWrapper> {
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
SharedPreferences.getInstance(),
|
SharedPreferences.getInstance(),
|
||||||
const LightSensorService(LocalPlatform()).hasSensor(),
|
const LightSensorService(LocalPlatform()).hasSensor(),
|
||||||
|
const CameraInfoService().mainCameraEfl(),
|
||||||
remoteConfigService.activeAndFetchFeatures(),
|
remoteConfigService.activeAndFetchFeatures(),
|
||||||
equipmentProfilesStorageService.init(),
|
equipmentProfilesStorageService.init(),
|
||||||
filmsStorageService.init(),
|
filmsStorageService.init(),
|
||||||
]).then((value) {
|
]).then((value) {
|
||||||
userPreferencesService = UserPreferencesService((value[0] as SharedPreferences?)!);
|
userPreferencesService = UserPreferencesService((value[0] as SharedPreferences?)!)
|
||||||
|
..cameraFocalLength = value[2] as int?;
|
||||||
hasLightSensor = value[1] as bool? ?? false;
|
hasLightSensor = value[1] as bool? ?? false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class CaffeineService {
|
class CaffeineService {
|
||||||
static const _methodChannel = MethodChannel("com.vodemn.lightmeter/keepScreenOn");
|
@visibleForTesting
|
||||||
|
static const caffeineMethodChannel = MethodChannel("com.vodemn.lightmeter.CaffeinePlatformChannel.MethodChannel");
|
||||||
|
|
||||||
const CaffeineService();
|
const CaffeineService();
|
||||||
|
|
||||||
Future<bool> isKeepScreenOn() async {
|
Future<bool> isKeepScreenOn() async {
|
||||||
return _methodChannel.invokeMethod<bool>("isKeepScreenOn").then((value) => value!);
|
return caffeineMethodChannel.invokeMethod<bool>("isKeepScreenOn").then((value) => value!);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> keepScreenOn(bool keep) async {
|
Future<bool> keepScreenOn(bool keep) async {
|
||||||
return _methodChannel.invokeMethod<bool>("setKeepScreenOn", keep).then((value) => value!);
|
return caffeineMethodChannel.invokeMethod<bool>("setKeepScreenOn", keep).then((value) => value!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
lib/data/camera_info_service.dart
Normal file
16
lib/data/camera_info_service.dart
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class CameraInfoService {
|
||||||
|
@visibleForTesting
|
||||||
|
static const cameraInfoPlatformChannel = MethodChannel(
|
||||||
|
"com.vodemn.lightmeter.CameraInfoPlatformChannel.MethodChannel",
|
||||||
|
);
|
||||||
|
|
||||||
|
const CameraInfoService();
|
||||||
|
|
||||||
|
Future<int?> mainCameraEfl() async {
|
||||||
|
final focalLength = await cameraInfoPlatformChannel.invokeMethod<double?>('mainCameraEfl');
|
||||||
|
return focalLength?.round();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
enum CameraFeature {
|
enum CameraFeature {
|
||||||
spotMetering,
|
spotMetering,
|
||||||
histogram,
|
histogram,
|
||||||
|
showFocalLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef CameraFeaturesConfig = Map<CameraFeature, bool>;
|
typedef CameraFeaturesConfig = Map<CameraFeature, bool>;
|
||||||
|
|
|
@ -22,6 +22,7 @@ class UserPreferencesService {
|
||||||
static const lightSensorEvCalibrationKey = "lightSensorEvCalibration";
|
static const lightSensorEvCalibrationKey = "lightSensorEvCalibration";
|
||||||
static const meteringScreenLayoutKey = "meteringScreenLayout";
|
static const meteringScreenLayoutKey = "meteringScreenLayout";
|
||||||
static const cameraFeaturesKey = "cameraFeatures";
|
static const cameraFeaturesKey = "cameraFeatures";
|
||||||
|
static const cameraFocalLengthKey = "cameraFocalLength";
|
||||||
|
|
||||||
static const caffeineKey = "caffeine";
|
static const caffeineKey = "caffeine";
|
||||||
static const hapticsKey = "haptics";
|
static const hapticsKey = "haptics";
|
||||||
|
@ -118,6 +119,7 @@ class UserPreferencesService {
|
||||||
return {
|
return {
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: false,
|
||||||
CameraFeature.histogram: false,
|
CameraFeature.histogram: false,
|
||||||
|
CameraFeature.showFocalLength: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +127,9 @@ class UserPreferencesService {
|
||||||
set cameraFeatures(CameraFeaturesConfig value) =>
|
set cameraFeatures(CameraFeaturesConfig value) =>
|
||||||
_sharedPreferences.setString(cameraFeaturesKey, json.encode(value.toJson()));
|
_sharedPreferences.setString(cameraFeaturesKey, json.encode(value.toJson()));
|
||||||
|
|
||||||
|
int? get cameraFocalLength => _sharedPreferences.getInt(cameraFocalLengthKey);
|
||||||
|
set cameraFocalLength(int? value) => _sharedPreferences.setInt(cameraFocalLengthKey, value!);
|
||||||
|
|
||||||
bool get caffeine => _sharedPreferences.getBool(caffeineKey) ?? false;
|
bool get caffeine => _sharedPreferences.getBool(caffeineKey) ?? false;
|
||||||
set caffeine(bool value) => _sharedPreferences.setBool(caffeineKey, value);
|
set caffeine(bool value) => _sharedPreferences.setBool(caffeineKey, value);
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ class VolumeEventsService {
|
||||||
final LocalPlatform _localPlatform;
|
final LocalPlatform _localPlatform;
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static const volumeHandlingChannel = MethodChannel("com.vodemn.lightmeter/volumeHandling");
|
static const volumeMethodChannel = MethodChannel("com.vodemn.lightmeter.VolumePlatformChannel.MethodChannel");
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
static const volumeEventsChannel = EventChannel("com.vodemn.lightmeter/volumeEvents");
|
static const volumeEventsChannel = EventChannel("com.vodemn.lightmeter.VolumePlatformChannel.EventChannel");
|
||||||
|
|
||||||
const VolumeEventsService(this._localPlatform);
|
const VolumeEventsService(this._localPlatform);
|
||||||
|
|
||||||
|
@ -19,9 +19,7 @@ class VolumeEventsService {
|
||||||
if (!_localPlatform.isAndroid) {
|
if (!_localPlatform.isAndroid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return volumeHandlingChannel
|
return volumeMethodChannel.invokeMethod<bool>("setVolumeHandling", enableHandling).then((value) => value!);
|
||||||
.invokeMethod<bool>("setVolumeHandling", enableHandling)
|
|
||||||
.then((value) => value!);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emits new events on
|
/// Emits new events on
|
||||||
|
@ -32,9 +30,6 @@ class VolumeEventsService {
|
||||||
if (!_localPlatform.isAndroid) {
|
if (!_localPlatform.isAndroid) {
|
||||||
return const Stream.empty();
|
return const Stream.empty();
|
||||||
}
|
}
|
||||||
return volumeEventsChannel
|
return volumeEventsChannel.receiveBroadcastStream().cast<int>().where((event) => event == 24 || event == 25);
|
||||||
.receiveBroadcastStream()
|
|
||||||
.cast<int>()
|
|
||||||
.where((event) => event == 24 || event == 25);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,7 @@ class MeteringInteractor {
|
||||||
if (_userPreferencesService.caffeine) {
|
if (_userPreferencesService.caffeine) {
|
||||||
_caffeineService.keepScreenOn(true);
|
_caffeineService.keepScreenOn(true);
|
||||||
}
|
}
|
||||||
_volumeEventsService
|
_volumeEventsService.setVolumeHandling(_userPreferencesService.volumeAction != VolumeAction.none);
|
||||||
.setVolumeHandling(_userPreferencesService.volumeAction != VolumeAction.none);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double get cameraEvCalibration => _userPreferencesService.cameraEvCalibration;
|
double get cameraEvCalibration => _userPreferencesService.cameraEvCalibration;
|
||||||
|
@ -62,15 +61,11 @@ class MeteringInteractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> checkCameraPermission() async {
|
Future<bool> checkCameraPermission() async {
|
||||||
return _permissionsService
|
return _permissionsService.checkCameraPermission().then((value) => value == PermissionStatus.granted);
|
||||||
.checkCameraPermission()
|
|
||||||
.then((value) => value == PermissionStatus.granted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> requestCameraPermission() async {
|
Future<bool> requestCameraPermission() async {
|
||||||
return _permissionsService
|
return _permissionsService.requestCameraPermission().then((value) => value == PermissionStatus.granted);
|
||||||
.requestCameraPermission()
|
|
||||||
.then((value) => value == PermissionStatus.granted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void openAppSettings() {
|
void openAppSettings() {
|
||||||
|
@ -80,4 +75,6 @@ class MeteringInteractor {
|
||||||
Future<bool> hasAmbientLightSensor() async => _lightSensorService.hasSensor();
|
Future<bool> hasAmbientLightSensor() async => _lightSensorService.hasSensor();
|
||||||
|
|
||||||
Stream<int> luxStream() => _lightSensorService.luxStream();
|
Stream<int> luxStream() => _lightSensorService.luxStream();
|
||||||
|
|
||||||
|
void setCameraFocalLength(int focalLength) => _userPreferencesService.cameraFocalLength = focalLength;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
"cameraFeatureSpotMeteringHint": "Halte die Kameraansicht gedrückt um den Messpunkt zu entfernen",
|
"cameraFeatureSpotMeteringHint": "Halte die Kameraansicht gedrückt um den Messpunkt zu entfernen",
|
||||||
"cameraFeatureHistogram": "Histogramm",
|
"cameraFeatureHistogram": "Histogramm",
|
||||||
"cameraFeatureHistogramHint": "Verwendung des Histogramms kann den Batterieverbrauch erhöhen",
|
"cameraFeatureHistogramHint": "Verwendung des Histogramms kann den Batterieverbrauch erhöhen",
|
||||||
|
"cameraFeaturesShowFocalLength": "Brennweite anzeigen",
|
||||||
|
"cameraFeaturesShowFocalLengthHint": "Zeigt die 35mm-äquivalente Brennweite statt des Zoomfaktors an",
|
||||||
"film": "Film",
|
"film": "Film",
|
||||||
"filmPush": "Film (push)",
|
"filmPush": "Film (push)",
|
||||||
"filmPull": "Film (pull)",
|
"filmPull": "Film (pull)",
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
"cameraFeatureSpotMeteringHint": "Long press the camera view to remove metering spot",
|
"cameraFeatureSpotMeteringHint": "Long press the camera view to remove metering spot",
|
||||||
"cameraFeatureHistogram": "Histogram",
|
"cameraFeatureHistogram": "Histogram",
|
||||||
"cameraFeatureHistogramHint": "Enabling histogram can encrease battery drain",
|
"cameraFeatureHistogramHint": "Enabling histogram can encrease battery drain",
|
||||||
|
"cameraFeaturesShowFocalLength": "Show Focal Length",
|
||||||
|
"cameraFeaturesShowFocalLengthHint": "Displays 35mm equivalent focal length instead of zoom factor",
|
||||||
"film": "Film",
|
"film": "Film",
|
||||||
"filmPush": "Film (push)",
|
"filmPush": "Film (push)",
|
||||||
"filmPull": "Film (pull)",
|
"filmPull": "Film (pull)",
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
"cameraFeatureSpotMeteringHint": "Appuyez longuement sur la vue de l'appareil photo pour supprimer le spot de mesure",
|
"cameraFeatureSpotMeteringHint": "Appuyez longuement sur la vue de l'appareil photo pour supprimer le spot de mesure",
|
||||||
"cameraFeatureHistogram": "Histogramme",
|
"cameraFeatureHistogram": "Histogramme",
|
||||||
"cameraFeatureHistogramHint": "L'activation de l'histogramme peut augmenter la consommation de la batterie",
|
"cameraFeatureHistogramHint": "L'activation de l'histogramme peut augmenter la consommation de la batterie",
|
||||||
|
"cameraFeaturesShowFocalLength": "Afficher la focale",
|
||||||
|
"cameraFeaturesShowFocalLengthHint": "Affiche la focale équivalente 35 mm au lieu du facteur de zoom",
|
||||||
"film": "Pellicule",
|
"film": "Pellicule",
|
||||||
"filmPush": "Pellicule (push)",
|
"filmPush": "Pellicule (push)",
|
||||||
"filmPull": "Pellicule (pull)",
|
"filmPull": "Pellicule (pull)",
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
"cameraFeatureSpotMeteringHint": "Используйте долгое нажатие, чтобы удалить точку замера",
|
"cameraFeatureSpotMeteringHint": "Используйте долгое нажатие, чтобы удалить точку замера",
|
||||||
"cameraFeatureHistogram": "Гистограмма",
|
"cameraFeatureHistogram": "Гистограмма",
|
||||||
"cameraFeatureHistogramHint": "Использование гистограммы может увеличить расход аккумулятора",
|
"cameraFeatureHistogramHint": "Использование гистограммы может увеличить расход аккумулятора",
|
||||||
|
"cameraFeaturesShowFocalLength": "Показать фокусное расстояние",
|
||||||
|
"cameraFeaturesShowFocalLengthHint": "Показывает эквивалент фокусного расстояния (35 мм) вместо коэффициента зума",
|
||||||
"film": "Пленка",
|
"film": "Пленка",
|
||||||
"filmPush": "Пленка (push)",
|
"filmPush": "Пленка (push)",
|
||||||
"filmPull": "Пленка (pull)",
|
"filmPull": "Пленка (pull)",
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
"cameraFeatureSpotMeteringHint": "长按相机视图可移除测光点",
|
"cameraFeatureSpotMeteringHint": "长按相机视图可移除测光点",
|
||||||
"cameraFeatureHistogram": "直方图",
|
"cameraFeatureHistogram": "直方图",
|
||||||
"cameraFeatureHistogramHint": "启用直方图会增加电池消耗",
|
"cameraFeatureHistogramHint": "启用直方图会增加电池消耗",
|
||||||
|
"cameraFeaturesShowFocalLength": "显示焦距",
|
||||||
|
"cameraFeaturesShowFocalLengthHint": "显示 35mm 等效焦距而非变焦倍数",
|
||||||
"film": "胶片",
|
"film": "胶片",
|
||||||
"filmPush": "胶片 (push)",
|
"filmPush": "胶片 (push)",
|
||||||
"filmPull": "胶片 (pull)",
|
"filmPull": "胶片 (pull)",
|
||||||
|
|
|
@ -247,7 +247,7 @@ class _LensZoomListTileBuilder extends StatelessWidget {
|
||||||
description: S.of(context).lensZoomDescription,
|
description: S.of(context).lensZoomDescription,
|
||||||
value: state.lensZoom,
|
value: state.lensZoom,
|
||||||
range: const RangeValues(1, 7),
|
range: const RangeValues(1, 7),
|
||||||
valueAdapter: (_, value) => value.toZoom(),
|
valueAdapter: (context, value) => value.toZoom(context),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context.read<EquipmentProfileEditBloc>().add(EquipmentProfileLensZoomChangedEvent(value));
|
context.read<EquipmentProfileEditBloc>().add(EquipmentProfileLensZoomChangedEvent(value));
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'dart:io';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
|
import 'package:exif/exif.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -17,7 +18,7 @@ import 'package:lightmeter/screens/metering/components/camera_container/event_co
|
||||||
import 'package:lightmeter/screens/metering/components/camera_container/models/camera_error_type.dart';
|
import 'package:lightmeter/screens/metering/components/camera_container/models/camera_error_type.dart';
|
||||||
import 'package:lightmeter/screens/metering/components/camera_container/state_container_camera.dart';
|
import 'package:lightmeter/screens/metering/components/camera_container/state_container_camera.dart';
|
||||||
import 'package:lightmeter/screens/metering/components/shared/ev_source_base/bloc_base_ev_source.dart';
|
import 'package:lightmeter/screens/metering/components/shared/ev_source_base/bloc_base_ev_source.dart';
|
||||||
import 'package:lightmeter/utils/ev_from_bytes.dart';
|
import 'package:lightmeter/utils/exif_utils.dart';
|
||||||
|
|
||||||
part 'mock_bloc_container_camera.part.dart';
|
part 'mock_bloc_container_camera.part.dart';
|
||||||
|
|
||||||
|
@ -184,7 +185,8 @@ class CameraContainerBloc extends EvSourceBlocBase<CameraContainerEvent, CameraC
|
||||||
_cameraController = cameraController;
|
_cameraController = cameraController;
|
||||||
emit(CameraInitializedState(cameraController));
|
emit(CameraInitializedState(cameraController));
|
||||||
_emitActiveState(emit);
|
_emitActiveState(emit);
|
||||||
} catch (e) {
|
} catch (e, stackTrace) {
|
||||||
|
_analytics.logCrash(e, stackTrace);
|
||||||
emit(const CameraErrorState(CameraErrorType.other));
|
emit(const CameraErrorState(CameraErrorType.other));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +249,8 @@ class CameraContainerBloc extends EvSourceBlocBase<CameraContainerEvent, CameraC
|
||||||
final file = await _cameraController!.takePicture();
|
final file = await _cameraController!.takePicture();
|
||||||
final bytes = await file.readAsBytes();
|
final bytes = await file.readAsBytes();
|
||||||
Directory(file.path).deleteSync(recursive: true);
|
Directory(file.path).deleteSync(recursive: true);
|
||||||
return await evFromImage(bytes);
|
final tags = await readExifFromBytes(bytes);
|
||||||
|
return evFromTags(tags);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
_analytics.logCrash(e, stackTrace);
|
_analytics.logCrash(e, stackTrace);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ZoomSlider extends StatelessWidget {
|
||||||
icon: Icons.search_outlined,
|
icon: Icons.search_outlined,
|
||||||
defaultValue: EquipmentProfiles.selectedOf(context).lensZoom,
|
defaultValue: EquipmentProfiles.selectedOf(context).lensZoom,
|
||||||
rulerValueAdapter: (value) => value.toStringAsFixed(0),
|
rulerValueAdapter: (value) => value.toStringAsFixed(0),
|
||||||
valueAdapter: (value) => value.toZoom(),
|
valueAdapter: (value) => value.toZoom(context),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ class MockCameraContainerBloc extends CameraContainerBloc {
|
||||||
Future<double?> _takePhoto() async {
|
Future<double?> _takePhoto() async {
|
||||||
try {
|
try {
|
||||||
final bytes = (await rootBundle.load(PlatformConfig.cameraStubImage)).buffer.asUint8List();
|
final bytes = (await rootBundle.load(PlatformConfig.cameraStubImage)).buffer.asUint8List();
|
||||||
return await evFromImage(bytes);
|
final tags = await readExifFromBytes(bytes);
|
||||||
|
return evFromTags(tags);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
log(e.toString(), stackTrace: stackTrace);
|
log(e.toString(), stackTrace: stackTrace);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/data/models/camera_feature.dart';
|
import 'package:lightmeter/data/models/camera_feature.dart';
|
||||||
import 'package:lightmeter/generated/l10n.dart';
|
import 'package:lightmeter/generated/l10n.dart';
|
||||||
|
import 'package:lightmeter/providers/services_provider.dart';
|
||||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||||
import 'package:lightmeter/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart';
|
import 'package:lightmeter/screens/settings/components/shared/dialog_switch/widget_dialog_switch.dart';
|
||||||
import 'package:lightmeter/screens/settings/components/shared/iap_list_tile/widget_list_tile_iap.dart';
|
import 'package:lightmeter/screens/settings/components/shared/iap_list_tile/widget_list_tile_iap.dart';
|
||||||
|
@ -20,21 +21,21 @@ class CameraFeaturesListTile extends StatelessWidget {
|
||||||
icon: Icons.camera_alt_outlined,
|
icon: Icons.camera_alt_outlined,
|
||||||
title: S.of(context).cameraFeatures,
|
title: S.of(context).cameraFeatures,
|
||||||
values: UserPreferencesProvider.cameraConfigOf(context),
|
values: UserPreferencesProvider.cameraConfigOf(context),
|
||||||
titleAdapter: (context, feature) {
|
enabledAdapter: (feature) => switch (feature) {
|
||||||
switch (feature) {
|
CameraFeature.spotMetering => true,
|
||||||
case CameraFeature.spotMetering:
|
CameraFeature.histogram => true,
|
||||||
return S.of(context).cameraFeatureSpotMetering;
|
CameraFeature.showFocalLength =>
|
||||||
case CameraFeature.histogram:
|
ServicesProvider.of(context).userPreferencesService.cameraFocalLength != null,
|
||||||
return S.of(context).cameraFeatureHistogram;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
subtitleAdapter: (context, feature) {
|
titleAdapter: (context, feature) => switch (feature) {
|
||||||
switch (feature) {
|
CameraFeature.spotMetering => S.of(context).cameraFeatureSpotMetering,
|
||||||
case CameraFeature.spotMetering:
|
CameraFeature.histogram => S.of(context).cameraFeatureHistogram,
|
||||||
return S.of(context).cameraFeatureSpotMeteringHint;
|
CameraFeature.showFocalLength => S.of(context).cameraFeaturesShowFocalLength,
|
||||||
case CameraFeature.histogram:
|
},
|
||||||
return S.of(context).cameraFeatureHistogramHint;
|
subtitleAdapter: (context, feature) => switch (feature) {
|
||||||
}
|
CameraFeature.spotMetering => S.of(context).cameraFeatureSpotMeteringHint,
|
||||||
|
CameraFeature.histogram => S.of(context).cameraFeatureHistogramHint,
|
||||||
|
CameraFeature.showFocalLength => S.of(context).cameraFeaturesShowFocalLengthHint,
|
||||||
},
|
},
|
||||||
onSave: UserPreferencesProvider.of(context).setCameraFeature,
|
onSave: UserPreferencesProvider.of(context).setCameraFeature,
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lightmeter/data/models/camera_feature.dart';
|
||||||
|
import 'package:lightmeter/providers/services_provider.dart';
|
||||||
|
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||||
|
|
||||||
extension DoubleToZoom on double {
|
extension DoubleToZoom on double {
|
||||||
String toZoom() => 'x${toStringAsFixed(2)}';
|
String toZoom(BuildContext context) {
|
||||||
|
final showFocalLength = UserPreferencesProvider.cameraFeatureOf(context, CameraFeature.showFocalLength);
|
||||||
|
final cameraFocalLength = ServicesProvider.of(context).userPreferencesService.cameraFocalLength;
|
||||||
|
|
||||||
|
if (showFocalLength && cameraFocalLength != null) {
|
||||||
|
ServicesProvider.of(context).userPreferencesService.cameraFocalLength;
|
||||||
|
final zoomedFocalLength = (this * cameraFocalLength).round();
|
||||||
|
return '${zoomedFocalLength}mm';
|
||||||
|
} else {
|
||||||
|
return 'x${toStringAsFixed(2)}';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:exif/exif.dart';
|
import 'package:exif/exif.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
const String _isoExifKey = 'EXIF ISOSpeedRatings';
|
const String _isoExifKey = 'EXIF ISOSpeedRatings';
|
||||||
const String _apertureExifKey = 'EXIF FNumber';
|
const String _apertureExifKey = 'EXIF FNumber';
|
||||||
const String _shutterSpeedExifKey = 'EXIF ExposureTime';
|
const String _shutterSpeedExifKey = 'EXIF ExposureTime';
|
||||||
|
|
||||||
Future<double> evFromImage(Uint8List bytes) async {
|
double evFromTags(Map<String, IfdTag> tags) {
|
||||||
final tags = await readExifFromBytes(bytes);
|
|
||||||
final iso = double.tryParse("${tags[_isoExifKey]}");
|
final iso = double.tryParse("${tags[_isoExifKey]}");
|
||||||
final apertureValueRatio = (tags[_apertureExifKey]?.values as IfdRatios?)?.ratios.first;
|
final apertureValueRatio = (tags[_apertureExifKey]?.values as IfdRatios?)?.ratios.first;
|
||||||
final speedValueRatio = (tags[_shutterSpeedExifKey]?.values as IfdRatios?)?.ratios.first;
|
final speedValueRatio = (tags[_shutterSpeedExifKey]?.values as IfdRatios?)?.ratios.first;
|
||||||
|
|
||||||
if (iso == null || apertureValueRatio == null || speedValueRatio == null) {
|
if (iso == null || apertureValueRatio == null || speedValueRatio == null) {
|
||||||
throw ArgumentError(
|
throw ArgumentError(
|
||||||
'Error parsing EXIF',
|
'Error calculating EV',
|
||||||
[
|
[
|
||||||
if (iso == null) '$_isoExifKey: ${tags[_isoExifKey]?.printable} ${tags[_isoExifKey]?.printable.runtimeType}',
|
if (iso == null) '$_isoExifKey: ${tags[_isoExifKey]?.printable} ${tags[_isoExifKey]?.printable.runtimeType}',
|
||||||
if (apertureValueRatio == null) '$_apertureExifKey: $apertureValueRatio',
|
if (apertureValueRatio == null) '$_apertureExifKey: $apertureValueRatio',
|
|
@ -6,6 +6,7 @@ import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
import 'package:lightmeter/data/models/camera_feature.dart';
|
||||||
import 'package:lightmeter/data/models/ev_source_type.dart';
|
import 'package:lightmeter/data/models/ev_source_type.dart';
|
||||||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||||
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
||||||
|
@ -68,6 +69,14 @@ void main() {
|
||||||
}.toJson(),
|
}.toJson(),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
UserPreferencesService.cameraFeaturesKey: json.encode(
|
||||||
|
{
|
||||||
|
CameraFeature.spotMetering: false,
|
||||||
|
CameraFeature.histogram: false,
|
||||||
|
CameraFeature.showFocalLength: true,
|
||||||
|
}.toJson(),
|
||||||
|
),
|
||||||
|
|
||||||
/// General settings
|
/// General settings
|
||||||
UserPreferencesService.autostartTimerKey: false,
|
UserPreferencesService.autostartTimerKey: false,
|
||||||
UserPreferencesService.caffeineKey: true,
|
UserPreferencesService.caffeineKey: true,
|
||||||
|
|
|
@ -7,7 +7,6 @@ void main() {
|
||||||
|
|
||||||
late CaffeineService service;
|
late CaffeineService service;
|
||||||
|
|
||||||
const methodChannel = MethodChannel('com.vodemn.lightmeter/keepScreenOn');
|
|
||||||
Future<Object?>? methodCallSuccessHandler(MethodCall methodCall) async {
|
Future<Object?>? methodCallSuccessHandler(MethodCall methodCall) async {
|
||||||
switch (methodCall.method) {
|
switch (methodCall.method) {
|
||||||
case "isKeepScreenOn":
|
case "isKeepScreenOn":
|
||||||
|
@ -21,45 +20,57 @@ void main() {
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
service = const CaffeineService();
|
service = const CaffeineService();
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
.setMockMethodCallHandler(methodChannel, methodCallSuccessHandler);
|
CaffeineService.caffeineMethodChannel,
|
||||||
|
methodCallSuccessHandler,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
.setMockMethodCallHandler(methodChannel, null);
|
CaffeineService.caffeineMethodChannel,
|
||||||
|
null,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
group(
|
group(
|
||||||
'isKeepScreenOn()',
|
'isKeepScreenOn()',
|
||||||
() {
|
() {
|
||||||
test('true', () async {
|
test('true', () async {
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
.setMockMethodCallHandler(methodChannel, null);
|
CaffeineService.caffeineMethodChannel,
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
null,
|
||||||
.setMockMethodCallHandler(methodChannel, (methodCall) async {
|
);
|
||||||
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
|
CaffeineService.caffeineMethodChannel,
|
||||||
|
(methodCall) async {
|
||||||
switch (methodCall.method) {
|
switch (methodCall.method) {
|
||||||
case "isKeepScreenOn":
|
case "isKeepScreenOn":
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
expectLater(service.isKeepScreenOn(), completion(true));
|
expectLater(service.isKeepScreenOn(), completion(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('false', () async {
|
test('false', () async {
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
.setMockMethodCallHandler(methodChannel, null);
|
CaffeineService.caffeineMethodChannel,
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
null,
|
||||||
.setMockMethodCallHandler(methodChannel, (methodCall) async {
|
);
|
||||||
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
|
CaffeineService.caffeineMethodChannel,
|
||||||
|
(methodCall) async {
|
||||||
switch (methodCall.method) {
|
switch (methodCall.method) {
|
||||||
case "isKeepScreenOn":
|
case "isKeepScreenOn":
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
expectLater(service.isKeepScreenOn(), completion(false));
|
expectLater(service.isKeepScreenOn(), completion(false));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,11 +11,13 @@ void main() {
|
||||||
{
|
{
|
||||||
'spotMetering': true,
|
'spotMetering': true,
|
||||||
'histogram': true,
|
'histogram': true,
|
||||||
|
'showFocalLength': true,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: true,
|
CameraFeature.spotMetering: true,
|
||||||
CameraFeature.histogram: true,
|
CameraFeature.histogram: true,
|
||||||
|
CameraFeature.showFocalLength: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -26,6 +28,7 @@ void main() {
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: false,
|
||||||
CameraFeature.histogram: false,
|
CameraFeature.histogram: false,
|
||||||
|
CameraFeature.showFocalLength: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -272,6 +272,7 @@ void main() {
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: false,
|
||||||
CameraFeature.histogram: false,
|
CameraFeature.histogram: false,
|
||||||
|
CameraFeature.showFocalLength: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -284,6 +285,7 @@ void main() {
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: false,
|
||||||
CameraFeature.histogram: true,
|
CameraFeature.histogram: true,
|
||||||
|
CameraFeature.showFocalLength: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -292,17 +294,18 @@ void main() {
|
||||||
when(
|
when(
|
||||||
() => sharedPreferences.setString(
|
() => sharedPreferences.setString(
|
||||||
UserPreferencesService.cameraFeaturesKey,
|
UserPreferencesService.cameraFeaturesKey,
|
||||||
"""{"spotMetering":false,"histogram":true}""",
|
"""{"spotMetering":false,"histogram":true,"showFocalLength":true}""",
|
||||||
),
|
),
|
||||||
).thenAnswer((_) => Future.value(true));
|
).thenAnswer((_) => Future.value(true));
|
||||||
service.cameraFeatures = {
|
service.cameraFeatures = {
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: false,
|
||||||
CameraFeature.histogram: true,
|
CameraFeature.histogram: true,
|
||||||
|
CameraFeature.showFocalLength: true,
|
||||||
};
|
};
|
||||||
verify(
|
verify(
|
||||||
() => sharedPreferences.setString(
|
() => sharedPreferences.setString(
|
||||||
UserPreferencesService.cameraFeaturesKey,
|
UserPreferencesService.cameraFeaturesKey,
|
||||||
"""{"spotMetering":false,"histogram":true}""",
|
"""{"spotMetering":false,"histogram":true,"showFocalLength":true}""",
|
||||||
),
|
),
|
||||||
).called(1);
|
).called(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,14 +27,14 @@ void main() {
|
||||||
localPlatform = _MockLocalPlatform();
|
localPlatform = _MockLocalPlatform();
|
||||||
service = VolumeEventsService(localPlatform);
|
service = VolumeEventsService(localPlatform);
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
VolumeEventsService.volumeHandlingChannel,
|
VolumeEventsService.volumeMethodChannel,
|
||||||
methodCallSuccessHandler,
|
methodCallSuccessHandler,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
VolumeEventsService.volumeHandlingChannel,
|
VolumeEventsService.volumeMethodChannel,
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,6 +37,7 @@ void main() {
|
||||||
when(() => mockUserPreferencesService.cameraFeatures).thenReturn({
|
when(() => mockUserPreferencesService.cameraFeatures).thenReturn({
|
||||||
CameraFeature.spotMetering: true,
|
CameraFeature.spotMetering: true,
|
||||||
CameraFeature.histogram: true,
|
CameraFeature.histogram: true,
|
||||||
|
CameraFeature.showFocalLength: true,
|
||||||
});
|
});
|
||||||
when(() => mockUserPreferencesService.locale).thenReturn(SupportedLocale.en);
|
when(() => mockUserPreferencesService.locale).thenReturn(SupportedLocale.en);
|
||||||
when(() => mockUserPreferencesService.themeType).thenReturn(ThemeType.light);
|
when(() => mockUserPreferencesService.themeType).thenReturn(ThemeType.light);
|
||||||
|
@ -227,13 +228,6 @@ void main() {
|
||||||
expect(find.text("${MeteringScreenLayoutFeature.equipmentProfiles}: true"), findsNWidgets(2));
|
expect(find.text("${MeteringScreenLayoutFeature.equipmentProfiles}: true"), findsNWidgets(2));
|
||||||
expect(find.text("${MeteringScreenLayoutFeature.extremeExposurePairs}: false"), findsNWidgets(2));
|
expect(find.text("${MeteringScreenLayoutFeature.extremeExposurePairs}: false"), findsNWidgets(2));
|
||||||
expect(find.text("${MeteringScreenLayoutFeature.filmPicker}: false"), findsNWidgets(2));
|
expect(find.text("${MeteringScreenLayoutFeature.filmPicker}: false"), findsNWidgets(2));
|
||||||
verify(
|
|
||||||
() => mockUserPreferencesService.meteringScreenLayout = {
|
|
||||||
MeteringScreenLayoutFeature.extremeExposurePairs: false,
|
|
||||||
MeteringScreenLayoutFeature.filmPicker: false,
|
|
||||||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
|
||||||
},
|
|
||||||
).called(1);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -260,6 +254,7 @@ void main() {
|
||||||
onPressed: () => UserPreferencesProvider.of(context).setCameraFeature({
|
onPressed: () => UserPreferencesProvider.of(context).setCameraFeature({
|
||||||
CameraFeature.spotMetering: true,
|
CameraFeature.spotMetering: true,
|
||||||
CameraFeature.histogram: false,
|
CameraFeature.histogram: false,
|
||||||
|
CameraFeature.showFocalLength: false,
|
||||||
}),
|
}),
|
||||||
child: const Text(''),
|
child: const Text(''),
|
||||||
),
|
),
|
||||||
|
@ -270,15 +265,18 @@ void main() {
|
||||||
// Match `findsNWidgets(2)` to verify that `cameraFeatureOf` specific results are the same as the whole config
|
// Match `findsNWidgets(2)` to verify that `cameraFeatureOf` specific results are the same as the whole config
|
||||||
expect(find.text("${CameraFeature.spotMetering}: true"), findsNWidgets(2));
|
expect(find.text("${CameraFeature.spotMetering}: true"), findsNWidgets(2));
|
||||||
expect(find.text("${CameraFeature.histogram}: true"), findsNWidgets(2));
|
expect(find.text("${CameraFeature.histogram}: true"), findsNWidgets(2));
|
||||||
|
expect(find.text("${CameraFeature.showFocalLength}: true"), findsNWidgets(2));
|
||||||
|
|
||||||
await tester.tap(find.byType(ElevatedButton));
|
await tester.tap(find.byType(ElevatedButton));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text("${CameraFeature.spotMetering}: true"), findsNWidgets(2));
|
expect(find.text("${CameraFeature.spotMetering}: true"), findsNWidgets(2));
|
||||||
expect(find.text("${CameraFeature.histogram}: false"), findsNWidgets(2));
|
expect(find.text("${CameraFeature.histogram}: false"), findsNWidgets(2));
|
||||||
|
expect(find.text("${CameraFeature.showFocalLength}: false"), findsNWidgets(2));
|
||||||
verify(
|
verify(
|
||||||
() => mockUserPreferencesService.cameraFeatures = {
|
() => mockUserPreferencesService.cameraFeatures = {
|
||||||
CameraFeature.spotMetering: true,
|
CameraFeature.spotMetering: true,
|
||||||
CameraFeature.histogram: false,
|
CameraFeature.histogram: false,
|
||||||
|
CameraFeature.showFocalLength: false,
|
||||||
},
|
},
|
||||||
).called(1);
|
).called(1);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:lightmeter/utils/ev_from_bytes.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
group('evFromImage', () {
|
|
||||||
test(
|
|
||||||
'camera_stub_image.jpg',
|
|
||||||
() {
|
|
||||||
final bytes = File('assets/camera_stub_image.jpg').readAsBytesSync();
|
|
||||||
expectLater(evFromImage(bytes), completion(8.25230310752341));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'no EXIF',
|
|
||||||
() {
|
|
||||||
final bytes = File('assets/launcher_icon_dev_512.png').readAsBytesSync();
|
|
||||||
expectLater(evFromImage(bytes), throwsArgumentError);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
27
test/utils/exif_utils_test.dart
Normal file
27
test/utils/exif_utils_test.dart
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:exif/exif.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:lightmeter/utils/exif_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('evFromTags', () {
|
||||||
|
test(
|
||||||
|
'camera_stub_image.jpg',
|
||||||
|
() async {
|
||||||
|
final bytes = File('assets/camera_stub_image.jpg').readAsBytesSync();
|
||||||
|
final tags = await readExifFromBytes(bytes);
|
||||||
|
expect(evFromTags(tags), 8.25230310752341);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'no EXIF',
|
||||||
|
() async {
|
||||||
|
final bytes = File('assets/launcher_icon_dev_512.png').readAsBytesSync();
|
||||||
|
final tags = await readExifFromBytes(bytes);
|
||||||
|
expect(() => evFromTags(tags), throwsArgumentError);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue