diff --git a/quill_native_bridge/example/pubspec.lock b/quill_native_bridge/example/pubspec.lock index de86afa..5f78aea 100644 --- a/quill_native_bridge/example/pubspec.lock +++ b/quill_native_bridge/example/pubspec.lock @@ -244,7 +244,7 @@ packages: path: "../../quill_native_bridge_android" relative: true source: path - version: "0.0.1-dev.3" + version: "0.0.1-dev.4" quill_native_bridge_ios: dependency: "direct overridden" description: @@ -400,10 +400,10 @@ packages: dependency: transitive description: name: win32 - sha256: e1d0cc62e65dc2561f5071fcbccecf58ff20c344f8f3dc7d4922df372a11df1f + sha256: "10169d3934549017f0ae278ccb07f828f9d6ea21573bab0fb77b0e1ef0fce454" url: "https://pub.dev" source: hosted - version: "5.7.1" + version: "5.7.2" xml: dependency: transitive description: diff --git a/quill_native_bridge_android/CHANGELOG.md b/quill_native_bridge_android/CHANGELOG.md index b1038fd..821adac 100644 --- a/quill_native_bridge_android/CHANGELOG.md +++ b/quill_native_bridge_android/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 0.0.1-dev.4 + +- Fixes [build failure](https://github.com/singerdmx/flutter-quill/issues/2340) by avoiding `androidx.core.graphics.decodeBitmap` (causing compatibility issues). + ## 0.0.1-dev.3 - Require `quill_native_bridge_platform_interface` minimum version `0.0.1-dev.4`. diff --git a/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardReadImageHandler.kt b/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardReadImageHandler.kt index b2b805d..5709473 100644 --- a/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardReadImageHandler.kt +++ b/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardReadImageHandler.kt @@ -8,7 +8,6 @@ import android.graphics.BitmapFactory import android.graphics.ImageDecoder import android.net.Uri import android.os.Build -import androidx.core.graphics.decodeBitmap import dev.flutterquill.quill_native_bridge.generated.FlutterError import java.io.ByteArrayOutputStream import java.io.FileNotFoundException @@ -175,7 +174,7 @@ object ClipboardReadImageHandler { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { // Api 29 and above (use a newer API) val source = ImageDecoder.createSource(context.contentResolver, imageUri) - source.decodeBitmap { _, _ -> } + ImageDecoder.decodeBitmap(source) } else { // Backward compatibility with older versions checkNotNull(context.contentResolver.openInputStream(imageUri)) { diff --git a/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardWriteImageHandler.kt b/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardWriteImageHandler.kt index b1574c0..8a78540 100644 --- a/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardWriteImageHandler.kt +++ b/quill_native_bridge_android/android/src/main/kotlin/dev/flutterquill/quill_native_bridge/clipboard/ClipboardWriteImageHandler.kt @@ -19,7 +19,8 @@ object ClipboardWriteImageHandler { val bitmap: Bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { // Api 29 and above (use a newer API) try { - ImageDecoder.decodeBitmap(ImageDecoder.createSource(imageBytes)) + val source = ImageDecoder.createSource(imageBytes) + ImageDecoder.decodeBitmap(source) } catch (e: Exception) { throw FlutterError( "INVALID_IMAGE", diff --git a/quill_native_bridge_android/pubspec.yaml b/quill_native_bridge_android/pubspec.yaml index ed9021d..2647f4e 100644 --- a/quill_native_bridge_android/pubspec.yaml +++ b/quill_native_bridge_android/pubspec.yaml @@ -1,6 +1,6 @@ name: quill_native_bridge_android description: "Android implementation of the quill_native_bridge plugin." -version: 0.0.1-dev.3 +version: 0.0.1-dev.4 homepage: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge_android repository: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge_android issue_tracker: https://github.com/FlutterQuill/quill-native-bridge/issues?q=is%3Aissue+is%3Aopen+label%3A%22platform-android%22 diff --git a/quill_native_bridge_android/test/bug_fix_test.dart b/quill_native_bridge_android/test/bug_fix_test.dart new file mode 100644 index 0000000..c68f419 --- /dev/null +++ b/quill_native_bridge_android/test/bug_fix_test.dart @@ -0,0 +1,32 @@ +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test( + 'ensure compatibility by avoiding unresolved image decoder import (See https://github.com/singerdmx/flutter-quill/issues/2340)', + () { + // TODO: Avoid hardcoding the `dev/flutterquill/quill_native_bridge/` + // in here and in pigeons/messages.dart + final targetDirectory = Directory( + 'android/src/main/kotlin/dev/flutterquill/quill_native_bridge/'); + + expect(targetDirectory.existsSync(), isTrue, + reason: 'Target directory does not exist: ${targetDirectory.path}'); + + for (final entity in targetDirectory.listSync(recursive: true)) { + if (entity is! File) { + continue; + } + final content = entity.readAsStringSync(); + expect( + content.contains('import androidx.core.graphics.decodeBitmap'), + isFalse, + reason: 'Compatibility issue detected in ${entity.path}. ' + 'Avoid using `androidx.core.graphics.decodeBitmap`. ' + 'For more details, see https://github.com/FlutterQuill/quill-native-bridge/pull/7', + ); + } + }, + ); +}