Skip to content

Commit

Permalink
Merge pull request #1025 from navaronbracke/release_5-0-0
Browse files Browse the repository at this point in the history
feat: Release 5.0.0
  • Loading branch information
navaronbracke authored Apr 22, 2024
2 parents 36e9f49 + 0c784cf commit 8c87026
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 5.0.0

This major release contains all the changes from the 5.0.0 beta releases, along with the following changes:

Improvements:
- [Android] Remove the Kotlin Standard Library from the dependencies, as it is automatically included in Kotlin 1.4+

## 5.0.0-beta.3

**BREAKING CHANGES:**
Expand Down
5 changes: 1 addition & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ group 'dev.steenbakker.mobile_scanner'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.7.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22"
}
}

Expand Down Expand Up @@ -64,8 +63,6 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

def useUnbundled = project.findProperty('dev.steenbakker.mobile_scanner.useUnbundled') ?: false
if (useUnbundled.toBoolean()) {
// Dynamically downloaded model via Google Play Services
Expand Down
13 changes: 11 additions & 2 deletions lib/src/web/media_track_constraints_delegate.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:js_interop';

import 'package:mobile_scanner/src/web/media_track_extension.dart';
import 'package:web/web.dart';

/// This class represents a delegate that manages the constraints for a [MediaStreamTrack].
Expand All @@ -17,10 +18,18 @@ final class MediaTrackConstraintsDelegate {

final MediaStreamTrack track = tracks.first;

final MediaTrackCapabilities capabilities = track.getCapabilities();
final MediaTrackCapabilities capabilities;

if (track.getCapabilitiesNullable != null) {
capabilities = track.getCapabilities();
} else {
capabilities = MediaTrackCapabilities();
}

final MediaTrackSettings settings = track.getSettings();
final JSArray<JSString>? facingModes = capabilities.facingModeNullable;

if (capabilities.facingMode.toDart.isEmpty) {
if (facingModes == null || facingModes.toDart.isEmpty) {
return MediaTrackSettings(
width: settings.width,
height: settings.height,
Expand Down
18 changes: 18 additions & 0 deletions lib/src/web/media_track_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'dart:js_interop';
import 'package:web/web.dart';

/// This extension provides nullable properties for [MediaStreamTrack],
/// for cases where the properties are not supported by all browsers.
extension NullableMediaStreamTrackCapabilities on MediaStreamTrack {
/// The `getCapabilities` function is not supported on Firefox.
@JS('getCapabilities')
external JSFunction? get getCapabilitiesNullable;
}

/// This extension provides nullable properties for [MediaTrackCapabilities],
/// for cases where the properties are not supported by all browsers.
extension NullableMediaTrackCapabilities on MediaTrackCapabilities {
/// The `facingMode` property is not supported on Safari.
@JS('facingMode')
external JSArray<JSString>? get facingModeNullable;
}
15 changes: 12 additions & 3 deletions lib/src/web/mobile_scanner_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:mobile_scanner/src/mobile_scanner_view_attributes.dart';
import 'package:mobile_scanner/src/objects/barcode_capture.dart';
import 'package:mobile_scanner/src/objects/start_options.dart';
import 'package:mobile_scanner/src/web/barcode_reader.dart';
import 'package:mobile_scanner/src/web/media_track_extension.dart';
import 'package:mobile_scanner/src/web/zxing/zxing_barcode_reader.dart';
import 'package:web/web.dart';

Expand Down Expand Up @@ -124,11 +125,19 @@ class MobileScannerWeb extends MobileScannerPlatform {
}

final MediaStreamTrack videoTrack = tracks.first;
final MediaTrackCapabilities capabilities = videoTrack.getCapabilities();
final MediaTrackCapabilities capabilities;

// TODO: this is empty on MacOS, where there is no facing mode, but one, user facing camera.
if (videoTrack.getCapabilitiesNullable != null) {
capabilities = videoTrack.getCapabilities();
} else {
capabilities = MediaTrackCapabilities();
}

final JSArray<JSString>? facingModes = capabilities.facingModeNullable;

// TODO: this is an empty array on MacOS Chrome, where there is no facing mode, but one, user facing camera.
// Facing mode is not supported by this track, do nothing.
if (capabilities.facingMode.toDart.isEmpty) {
if (facingModes == null || facingModes.toDart.isEmpty) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mobile_scanner
description: A universal barcode and QR code scanner for Flutter based on MLKit. Uses CameraX on Android, AVFoundation on iOS and Apple Vision & AVFoundation on macOS.
version: 5.0.0-beta.3
version: 5.0.0
repository: https://github.com/juliansteenbakker/mobile_scanner

screenshots:
Expand Down

0 comments on commit 8c87026

Please sign in to comment.