From 9a5bea1c016706701e8b5a50c8e6c2ba0bef2a14 Mon Sep 17 00:00:00 2001 From: hoonjae Date: Thu, 6 May 2021 08:29:13 +0900 Subject: [PATCH 1/6] android: remove preview size limit --- .../main/java/io/flutter/plugins/camera/Camera.java | 7 ++++--- .../java/io/flutter/plugins/camera/CameraUtils.java | 10 ---------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java index 4c1370f2f3cb..4bcb14a58b4b 100644 --- a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java +++ b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java @@ -4,8 +4,6 @@ package io.flutter.plugins.camera; -import static io.flutter.plugins.camera.CameraUtils.computeBestPreviewSize; - import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; @@ -85,6 +83,7 @@ public class Camera { private final String cameraName; private final Size captureSize; private final Size previewSize; + private final boolean takePictureWithMaxResolution; private final boolean enableAudio; private final Context applicationContext; private final CamcorderProfile recordingProfile; @@ -125,12 +124,14 @@ public Camera( final DartMessenger dartMessenger, final String cameraName, final String resolutionPreset, + final boolean takePictureWithMaxResolution, final boolean enableAudio) throws CameraAccessException { if (activity == null) { throw new IllegalStateException("No activity available!"); } this.cameraName = cameraName; + this.takePictureWithMaxResolution = takePictureWithMaxResolution; this.enableAudio = enableAudio; this.flutterTexture = flutterTexture; this.dartMessenger = dartMessenger; @@ -151,7 +152,7 @@ public Camera( recordingProfile = CameraUtils.getBestAvailableCamcorderProfileForResolutionPreset(cameraName, preset); captureSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight); - previewSize = computeBestPreviewSize(cameraName, preset); + previewSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight); cameraZoom = new CameraZoom( cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE), diff --git a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java index b4d4689f2b4e..dabb49310ab0 100644 --- a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java +++ b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/CameraUtils.java @@ -82,16 +82,6 @@ static PlatformChannel.DeviceOrientation deserializeDeviceOrientation(String ori } } - static Size computeBestPreviewSize(String cameraName, ResolutionPreset preset) { - if (preset.ordinal() > ResolutionPreset.high.ordinal()) { - preset = ResolutionPreset.high; - } - - CamcorderProfile profile = - getBestAvailableCamcorderProfileForResolutionPreset(cameraName, preset); - return new Size(profile.videoFrameWidth, profile.videoFrameHeight); - } - static Size computeBestCaptureSize(StreamConfigurationMap streamConfigurationMap) { // For still image captures, we use the largest available size. return Collections.max( From eff7cd301c3fca6e37bd1ce127497108bbd1d28b Mon Sep 17 00:00:00 2001 From: hoonjae Date: Thu, 6 May 2021 10:18:40 +0900 Subject: [PATCH 2/6] feat: add enableTakePictureWithMaxResolution both in android and iOS --- .../io/flutter/plugins/camera/Camera.java | 24 +++++++++++++++---- .../plugins/camera/MethodCallHandlerImpl.java | 2 ++ .../camera/camera/ios/Classes/CameraPlugin.m | 8 ++++++- .../camera/lib/src/camera_controller.dart | 7 ++++++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java index 4bcb14a58b4b..9a854520ee57 100644 --- a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java +++ b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java @@ -4,6 +4,8 @@ package io.flutter.plugins.camera; +import static io.flutter.plugins.camera.CameraUtils.computeBestCaptureSize; + import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; @@ -83,7 +85,7 @@ public class Camera { private final String cameraName; private final Size captureSize; private final Size previewSize; - private final boolean takePictureWithMaxResolution; + private final boolean enableTakePictureWithMaxResolution; private final boolean enableAudio; private final Context applicationContext; private final CamcorderProfile recordingProfile; @@ -124,14 +126,14 @@ public Camera( final DartMessenger dartMessenger, final String cameraName, final String resolutionPreset, - final boolean takePictureWithMaxResolution, + final boolean enableTakePictureWithMaxResolution, final boolean enableAudio) throws CameraAccessException { if (activity == null) { throw new IllegalStateException("No activity available!"); } this.cameraName = cameraName; - this.takePictureWithMaxResolution = takePictureWithMaxResolution; + this.enableTakePictureWithMaxResolution = enableTakePictureWithMaxResolution; this.enableAudio = enableAudio; this.flutterTexture = flutterTexture; this.dartMessenger = dartMessenger; @@ -151,8 +153,20 @@ public Camera( ResolutionPreset preset = ResolutionPreset.valueOf(resolutionPreset); recordingProfile = CameraUtils.getBestAvailableCamcorderProfileForResolutionPreset(cameraName, preset); - captureSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight); previewSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight); + if(enableTakePictureWithMaxResolution) + { + captureSize = computeBestCaptureSize(cameraCharacteristics + .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)); + Log.i("Camera", "enableTakePictureWithMaxResolution"); + } + else + { + captureSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight); + } + Log.i("Camera", "[Preview Resolution] :" + previewSize); + Log.i("Camera", "[Capture Resolution] :" + captureSize); + cameraZoom = new CameraZoom( cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE), @@ -318,7 +332,7 @@ public void onConfigured(@NonNull CameraCaptureSession session) { } cameraCaptureSession = session; - updateFpsRange(); + updateFpsRange(); updateFocus(focusMode); updateFlash(flashMode); updateExposure(exposureMode); diff --git a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java index 50bca6349217..40436b25b5e2 100644 --- a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java +++ b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java @@ -352,6 +352,7 @@ void stopListening() { private void instantiateCamera(MethodCall call, Result result) throws CameraAccessException { String cameraName = call.argument("cameraName"); String resolutionPreset = call.argument("resolutionPreset"); + boolean enableTakePictureWithMaxResolution = call.argument("enableTakePictureWithMaxResolution"); boolean enableAudio = call.argument("enableAudio"); TextureRegistry.SurfaceTextureEntry flutterSurfaceTexture = textureRegistry.createSurfaceTexture(); @@ -365,6 +366,7 @@ private void instantiateCamera(MethodCall call, Result result) throws CameraAcce dartMessenger, cameraName, resolutionPreset, + enableTakePictureWithMaxResolution, enableAudio); Map reply = new HashMap<>(); diff --git a/packages/camera/camera/ios/Classes/CameraPlugin.m b/packages/camera/camera/ios/Classes/CameraPlugin.m index 5c43f78a8c4b..75a82a0b2e4e 100644 --- a/packages/camera/camera/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera/ios/Classes/CameraPlugin.m @@ -306,6 +306,7 @@ @interface FLTCam : NSObject @property(readonly, nonatomic) int64_t textureId; @property(nonatomic, copy) void (^onFrameAvailable)(void); +@property BOOL enableTakePictureWithMaxResolution; @property BOOL enableAudio; @property(nonatomic) FLTImageStreamHandler *imageStreamHandler; @property(nonatomic) FlutterMethodChannel *methodChannel; @@ -353,6 +354,7 @@ @implementation FLTCam { - (instancetype)initWithCameraName:(NSString *)cameraName resolutionPreset:(NSString *)resolutionPreset +enableTakePictureWithMaxResolution:(BOOL)enableTakePictureWithMaxResolution enableAudio:(BOOL)enableAudio orientation:(UIDeviceOrientation)orientation dispatchQueue:(dispatch_queue_t)dispatchQueue @@ -364,6 +366,7 @@ - (instancetype)initWithCameraName:(NSString *)cameraName } @catch (NSError *e) { *error = e; } + _enableTakePictureWithMaxResolution = enableTakePictureWithMaxResolution; _enableAudio = enableAudio; _dispatchQueue = dispatchQueue; _captureSession = [[AVCaptureSession alloc] init]; @@ -459,7 +462,8 @@ - (void)updateOrientation:(UIDeviceOrientation)orientation - (void)captureToFile:(FlutterResult)result API_AVAILABLE(ios(10)) { AVCapturePhotoSettings *settings = [AVCapturePhotoSettings photoSettings]; - if (_resolutionPreset == max) { + if (_resolutionPreset == max || _enableTakePictureWithMaxResolution == true) { + NSLog(@"setHighResolutionPhotoEnabled"); [settings setHighResolutionPhotoEnabled:YES]; } @@ -1332,10 +1336,12 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)re } else if ([@"create" isEqualToString:call.method]) { NSString *cameraName = call.arguments[@"cameraName"]; NSString *resolutionPreset = call.arguments[@"resolutionPreset"]; + NSNumber *enableTakePictureWithMaxResolution = call.arguments[@"enableTakePictureWithMaxResolution"]; NSNumber *enableAudio = call.arguments[@"enableAudio"]; NSError *error; FLTCam *cam = [[FLTCam alloc] initWithCameraName:cameraName resolutionPreset:resolutionPreset + enableTakePictureWithMaxResolution:[enableTakePictureWithMaxResolution boolValue] enableAudio:[enableAudio boolValue] orientation:[[UIDevice currentDevice] orientation] dispatchQueue:_dispatchQueue diff --git a/packages/camera/camera/lib/src/camera_controller.dart b/packages/camera/camera/lib/src/camera_controller.dart index 3284a9b01fa2..4652080c1e3e 100644 --- a/packages/camera/camera/lib/src/camera_controller.dart +++ b/packages/camera/camera/lib/src/camera_controller.dart @@ -206,6 +206,7 @@ class CameraController extends ValueNotifier { CameraController( this.description, this.resolutionPreset, { + this.enableTakePictureWithMaxResolution = false, this.enableAudio = true, this.imageFormatGroup, }) : super(const CameraValue.uninitialized()); @@ -221,6 +222,11 @@ class CameraController extends ValueNotifier { /// See also: [ResolutionPreset]. final ResolutionPreset resolutionPreset; + /// Whether to use max resolution for takePicture method, + /// It may be higher than ResolutionPreset.max, because the max resolution is for still image. + /// When the value is false, resolution set in resolutionPreset will be used for takePicture. + final bool enableTakePictureWithMaxResolution; + /// Whether to include audio when recording a video. final bool enableAudio; @@ -272,6 +278,7 @@ class CameraController extends ValueNotifier { _cameraId = await CameraPlatform.instance.createCamera( description, resolutionPreset, + enableTakePictureWithMaxResolution: enableTakePictureWithMaxResolution, enableAudio: enableAudio, ); From 4f61b06d0cd306cd5b986d42170fe8153f761b2e Mon Sep 17 00:00:00 2001 From: hoonjae Date: Thu, 6 May 2021 10:24:24 +0900 Subject: [PATCH 3/6] fix: updated after run scripts --- .../java/io/flutter/plugins/camera/Camera.java | 16 +++++++--------- .../plugins/camera/MethodCallHandlerImpl.java | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java index 9a854520ee57..af3baecd6609 100644 --- a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java +++ b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java @@ -154,19 +154,17 @@ public Camera( recordingProfile = CameraUtils.getBestAvailableCamcorderProfileForResolutionPreset(cameraName, preset); previewSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight); - if(enableTakePictureWithMaxResolution) - { - captureSize = computeBestCaptureSize(cameraCharacteristics - .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)); + if (enableTakePictureWithMaxResolution) { + captureSize = + computeBestCaptureSize( + cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)); Log.i("Camera", "enableTakePictureWithMaxResolution"); - } - else - { + } else { captureSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight); } Log.i("Camera", "[Preview Resolution] :" + previewSize); Log.i("Camera", "[Capture Resolution] :" + captureSize); - + cameraZoom = new CameraZoom( cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE), @@ -332,7 +330,7 @@ public void onConfigured(@NonNull CameraCaptureSession session) { } cameraCaptureSession = session; - updateFpsRange(); + updateFpsRange(); updateFocus(focusMode); updateFlash(flashMode); updateExposure(exposureMode); diff --git a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java index 40436b25b5e2..8a0cc43babf3 100644 --- a/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java +++ b/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/MethodCallHandlerImpl.java @@ -352,7 +352,8 @@ void stopListening() { private void instantiateCamera(MethodCall call, Result result) throws CameraAccessException { String cameraName = call.argument("cameraName"); String resolutionPreset = call.argument("resolutionPreset"); - boolean enableTakePictureWithMaxResolution = call.argument("enableTakePictureWithMaxResolution"); + boolean enableTakePictureWithMaxResolution = + call.argument("enableTakePictureWithMaxResolution"); boolean enableAudio = call.argument("enableAudio"); TextureRegistry.SurfaceTextureEntry flutterSurfaceTexture = textureRegistry.createSurfaceTexture(); From 636a5bed6ebddd2d0621c065be3d2a596f2724db Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Tue, 4 May 2021 13:53:44 -0400 Subject: [PATCH 4/6] Update third_party license checking (#3844) In preparation for enabling license checks in flutter/packages, update the allowed licenses: - Allow our license, for cases where we've locally added files - Allow the license used by the bsdiff package --- script/tool/CHANGELOG.md | 4 ++++ .../tool/lib/src/license_check_command.dart | 21 ++++++++++++------- script/tool/pubspec.yaml | 2 +- .../tool/test/license_check_command_test.dart | 18 ++++++++++++++++ 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/script/tool/CHANGELOG.md b/script/tool/CHANGELOG.md index 0411a9e53ab1..3a9736c35b47 100644 --- a/script/tool/CHANGELOG.md +++ b/script/tool/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.1 + +- Update the allowed third-party licenses for flutter/packages. + ## 0.1.0+1 - Re-add the bin/ directory. diff --git a/script/tool/lib/src/license_check_command.dart b/script/tool/lib/src/license_check_command.dart index adb2f9315298..a6528640b828 100644 --- a/script/tool/lib/src/license_check_command.dart +++ b/script/tool/lib/src/license_check_command.dart @@ -52,10 +52,14 @@ const Set _ignoredFullBasenameList = { final List _thirdPartyLicenseBlockRegexes = [ // Third-party code used in url_launcher_web. RegExp( - r'^// Copyright 2017 Workiva Inc..*' - '^// Licensed under the Apache License, Version 2.0', + r'^// Copyright 2017 Workiva Inc\..*' + r'^// Licensed under the Apache License, Version 2\.0', multiLine: true, dotAll: true), + // bsdiff in flutter/packages. + RegExp(r'// Copyright 2003-2005 Colin Percival\. All rights reserved\.\n' + r'// Use of this source code is governed by a BSD-style license that can be\n' + r'// found in the LICENSE file\.\n'), ]; // The exact format of the BSD license that our license files should contain. @@ -158,16 +162,19 @@ class LicenseCheckCommand extends PluginCommand { _print('Checking ${file.path}'); final String content = await file.readAsString(); + final String firstParyLicense = + firstPartyLicenseBlockByExtension[p.extension(file.path)] ?? + defaultFirstParyLicenseBlock; if (_isThirdParty(file)) { + // Third-party directories allow either known third-party licenses, our + // the first-party license, as there may be local additions. if (!_thirdPartyLicenseBlockRegexes - .any((RegExp regex) => regex.hasMatch(content))) { + .any((RegExp regex) => regex.hasMatch(content)) && + !content.contains(firstParyLicense)) { unrecognizedThirdPartyFiles.add(file); } } else { - final String license = - firstPartyLicenseBlockByExtension[p.extension(file.path)] ?? - defaultFirstParyLicenseBlock; - if (!content.contains(license)) { + if (!content.contains(firstParyLicense)) { incorrectFirstPartyFiles.add(file); } } diff --git a/script/tool/pubspec.yaml b/script/tool/pubspec.yaml index 18631fef02d7..58dfc9fbd8b6 100644 --- a/script/tool/pubspec.yaml +++ b/script/tool/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_plugin_tools description: Productivity utils for flutter/plugins and flutter/packages repository: https://github.com/flutter/plugins/tree/master/script/tool -version: 0.1.0+1 +version: 0.1.1 dependencies: args: "^1.4.3" diff --git a/script/tool/test/license_check_command_test.dart b/script/tool/test/license_check_command_test.dart index 94606f54b764..23de2581b9be 100644 --- a/script/tool/test/license_check_command_test.dart +++ b/script/tool/test/license_check_command_test.dart @@ -269,6 +269,24 @@ void main() { expect(printedMessages, contains('All source files passed validation!')); }); + test('allows first-party code in a third_party directory', () async { + final File firstPartyFileInThirdParty = root + .childDirectory('a_plugin') + .childDirectory('lib') + .childDirectory('src') + .childDirectory('third_party') + .childFile('first_party.cc'); + firstPartyFileInThirdParty.createSync(recursive: true); + _writeLicense(firstPartyFileInThirdParty); + + await runner.run(['license-check']); + + // Sanity check that the test did actually check the file. + expect(printedMessages, + contains('Checking a_plugin/lib/src/third_party/first_party.cc')); + expect(printedMessages, contains('All source files passed validation!')); + }); + test('fails for licenses that the tool does not expect', () async { final File good = root.childFile('good.cc'); good.createSync(); From 96447b19c68a8a9230e38c2c6824523fa3adfdd1 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Tue, 4 May 2021 12:29:19 -0700 Subject: [PATCH 5/6] Add implement and registerWith method to plugins (#3833) --- packages/connectivity/connectivity_macos/CHANGELOG.md | 4 ++++ packages/connectivity/connectivity_macos/pubspec.yaml | 10 +++++++++- .../path_provider/path_provider/lib/path_provider.dart | 5 ++--- .../path_provider/path_provider_linux/CHANGELOG.md | 5 +++++ .../path_provider_linux/lib/path_provider_linux.dart | 2 +- .../path_provider/path_provider_linux/pubspec.yaml | 3 ++- .../test/path_provider_linux_test.dart | 8 ++++---- .../path_provider/path_provider_macos/CHANGELOG.md | 4 ++++ .../path_provider/path_provider_macos/pubspec.yaml | 3 ++- .../path_provider/path_provider_windows/CHANGELOG.md | 5 +++++ .../lib/src/path_provider_windows_real.dart | 5 +++++ .../lib/src/path_provider_windows_stub.dart | 5 +++++ .../path_provider/path_provider_windows/pubspec.yaml | 3 ++- .../test/path_provider_windows_test.dart | 6 ++++++ .../shared_preferences/lib/shared_preferences.dart | 5 ++--- .../shared_preferences_linux/CHANGELOG.md | 5 +++++ .../lib/shared_preferences_linux.dart | 7 +++++++ .../shared_preferences_linux/pubspec.yaml | 3 ++- .../test/shared_preferences_linux_test.dart | 10 ++++++++-- .../shared_preferences_macos/CHANGELOG.md | 4 ++++ .../shared_preferences_macos/pubspec.yaml | 3 ++- .../shared_preferences_windows/CHANGELOG.md | 5 +++++ .../lib/shared_preferences_windows.dart | 7 +++++++ .../shared_preferences_windows/pubspec.yaml | 4 ++-- .../test/shared_preferences_windows_test.dart | 9 +++++++-- 25 files changed, 107 insertions(+), 23 deletions(-) diff --git a/packages/connectivity/connectivity_macos/CHANGELOG.md b/packages/connectivity/connectivity_macos/CHANGELOG.md index 7031e48318dd..0d962362a99f 100644 --- a/packages/connectivity/connectivity_macos/CHANGELOG.md +++ b/packages/connectivity/connectivity_macos/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.1 + +* Add `implements` to pubspec.yaml. + ## 0.2.0 * Remove placeholder Dart file. diff --git a/packages/connectivity/connectivity_macos/pubspec.yaml b/packages/connectivity/connectivity_macos/pubspec.yaml index b78db9baa0d2..66e853c89e75 100644 --- a/packages/connectivity/connectivity_macos/pubspec.yaml +++ b/packages/connectivity/connectivity_macos/pubspec.yaml @@ -1,10 +1,11 @@ name: connectivity_macos description: macOS implementation of the connectivity plugin. -version: 0.2.0 +version: 0.2.1 homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity/connectivity_macos flutter: plugin: + implements: connectivity_platform_interface platforms: macos: pluginClass: ConnectivityPlugin @@ -16,6 +17,13 @@ environment: dependencies: flutter: sdk: flutter + # The implementation of this plugin doesn't explicitly depend on the method channel + # defined in the platform interface. + # To prevent potential breakages, this dependency is added. + # + # In the future, this plugin's platform code should be able to reference the + # interface's platform code. (Android already supports this). + connectivity_platform_interface: ^2.0.0 dev_dependencies: pedantic: ^1.10.0 diff --git a/packages/path_provider/path_provider/lib/path_provider.dart b/packages/path_provider/path_provider/lib/path_provider.dart index 341b09f4a314..e690b7f92960 100644 --- a/packages/path_provider/path_provider/lib/path_provider.dart +++ b/packages/path_provider/path_provider/lib/path_provider.dart @@ -42,9 +42,8 @@ class MissingPlatformDirectoryException implements Exception { } PathProviderPlatform get _platform { - // This is to manually endorse Dart implementations until automatic - // registration of Dart plugins is implemented. For details see - // https://github.com/flutter/flutter/issues/52267. + // TODO(egarciad): Remove once auto registration lands on Flutter stable. + // https://github.com/flutter/flutter/issues/81421. if (_manualDartRegistrationNeeded) { // Only do the initial registration if it hasn't already been overridden // with a non-default instance. diff --git a/packages/path_provider/path_provider_linux/CHANGELOG.md b/packages/path_provider/path_provider_linux/CHANGELOG.md index a85c6bbb4ef3..9383181d6a76 100644 --- a/packages/path_provider/path_provider_linux/CHANGELOG.md +++ b/packages/path_provider/path_provider_linux/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.1 + +* Add `implements` to pubspec.yaml. +* Add `registerWith` method to the main Dart class. + ## 2.0.0 * Migrate to null safety. diff --git a/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart b/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart index 5a81114cc92d..38800bee1f2e 100644 --- a/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart +++ b/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart @@ -13,7 +13,7 @@ import 'package:xdg_directories/xdg_directories.dart' as xdg; /// This class implements the `package:path_provider` functionality for linux class PathProviderLinux extends PathProviderPlatform { /// Registers this class as the default instance of [PathProviderPlatform] - static void register() { + static void registerWith() { PathProviderPlatform.instance = PathProviderLinux(); } diff --git a/packages/path_provider/path_provider_linux/pubspec.yaml b/packages/path_provider/path_provider_linux/pubspec.yaml index 5d1c395aa418..b5bea8754dbe 100644 --- a/packages/path_provider/path_provider_linux/pubspec.yaml +++ b/packages/path_provider/path_provider_linux/pubspec.yaml @@ -1,10 +1,11 @@ name: path_provider_linux description: linux implementation of the path_provider plugin -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_linux flutter: plugin: + implements: path_provider platforms: linux: dartPluginClass: PathProviderLinux diff --git a/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart b/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart index 3384a3d2f963..e058d0d56039 100644 --- a/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart +++ b/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart @@ -7,11 +7,11 @@ import 'package:path_provider_platform_interface/path_provider_platform_interfac void main() { TestWidgetsFlutterBinding.ensureInitialized(); - PathProviderLinux.register(); + PathProviderLinux.registerWith(); - setUp(() {}); - - tearDown(() {}); + test('registered instance', () { + expect(PathProviderPlatform.instance, isA()); + }); test('getTemporaryPath', () async { final PathProviderPlatform plugin = PathProviderPlatform.instance; diff --git a/packages/path_provider/path_provider_macos/CHANGELOG.md b/packages/path_provider/path_provider_macos/CHANGELOG.md index f989efbe2a98..772ebcce8b8f 100644 --- a/packages/path_provider/path_provider_macos/CHANGELOG.md +++ b/packages/path_provider/path_provider_macos/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 + +* Add `implements` to pubspec.yaml. + ## 2.0.0 * Update Dart SDK constraint for null safety compatibility. diff --git a/packages/path_provider/path_provider_macos/pubspec.yaml b/packages/path_provider/path_provider_macos/pubspec.yaml index 522ef0a369af..3ebe43e62d9c 100644 --- a/packages/path_provider/path_provider_macos/pubspec.yaml +++ b/packages/path_provider/path_provider_macos/pubspec.yaml @@ -1,10 +1,11 @@ name: path_provider_macos description: macOS implementation of the path_provider plugin -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_macos flutter: plugin: + implements: path_provider platforms: macos: pluginClass: PathProviderPlugin diff --git a/packages/path_provider/path_provider_windows/CHANGELOG.md b/packages/path_provider/path_provider_windows/CHANGELOG.md index 02c3b2300fc0..2e4da0e1f353 100644 --- a/packages/path_provider/path_provider_windows/CHANGELOG.md +++ b/packages/path_provider/path_provider_windows/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.2 + +* Add `implements` to pubspec.yaml. +* Add `registerWith()` to the Dart main class. + ## 2.0.1 * Fix a crash when a known folder can't be located. diff --git a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart index 971967373438..2b87d51c1c49 100644 --- a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart +++ b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart @@ -47,6 +47,11 @@ class VersionInfoQuerier { /// /// This class implements the `package:path_provider` functionality for Windows. class PathProviderWindows extends PathProviderPlatform { + /// Registers the Windows implementation. + static void registerWith() { + PathProviderPlatform.instance = PathProviderWindows(); + } + /// The object to use for performing VerQueryValue calls. @visibleForTesting VersionInfoQuerier versionInfoQuerier = VersionInfoQuerier(); diff --git a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart index 91334d95ae24..bc851831bf54 100644 --- a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart +++ b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart @@ -16,6 +16,11 @@ class PathProviderWindows extends PathProviderPlatform { /// compile-time dependencies, and should never actually be created. PathProviderWindows() : assert(false); + /// Registers the Windows implementation. + static void registerWith() { + PathProviderPlatform.instance = PathProviderWindows(); + } + /// Stub; see comment on VersionInfoQuerier. VersionInfoQuerier versionInfoQuerier = VersionInfoQuerier(); diff --git a/packages/path_provider/path_provider_windows/pubspec.yaml b/packages/path_provider/path_provider_windows/pubspec.yaml index d0badefc8d7e..067fec4ceb78 100644 --- a/packages/path_provider/path_provider_windows/pubspec.yaml +++ b/packages/path_provider/path_provider_windows/pubspec.yaml @@ -1,10 +1,11 @@ name: path_provider_windows description: Windows implementation of the path_provider plugin homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_windows -version: 2.0.1 +version: 2.0.2 flutter: plugin: + implements: path_provider platforms: windows: dartPluginClass: PathProviderWindows diff --git a/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart b/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart index a66c9e1ffb0d..e977e07d99e6 100644 --- a/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart +++ b/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart @@ -5,6 +5,7 @@ import 'dart:ffi'; import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; +import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:path_provider_windows/path_provider_windows.dart'; // A fake VersionInfoQuerier that just returns preset responses. @@ -18,6 +19,11 @@ class FakeVersionInfoQuerier implements VersionInfoQuerier { } void main() { + test('registered instance', () { + PathProviderWindows.registerWith(); + expect(PathProviderPlatform.instance, isA()); + }); + test('getTemporaryPath', () async { final PathProviderWindows pathProvider = PathProviderWindows(); expect(await pathProvider.getTemporaryPath(), contains(r'C:\')); diff --git a/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart b/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart index 493e38901ddf..3d2dd051f61c 100644 --- a/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart +++ b/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart @@ -24,9 +24,8 @@ class SharedPreferences { static bool _manualDartRegistrationNeeded = true; static SharedPreferencesStorePlatform get _store { - // This is to manually endorse the Linux implementation until automatic - // registration of dart plugins is implemented. For details see - // https://github.com/flutter/flutter/issues/52267. + // TODO(egarciad): Remove once auto registration lands on Flutter stable. + // https://github.com/flutter/flutter/issues/81421. if (_manualDartRegistrationNeeded) { // Only do the initial registration if it hasn't already been overridden // with a non-default instance. diff --git a/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md b/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md index a50b4e470c53..9a17d2455ad8 100644 --- a/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md +++ b/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.1 + +* Add `implements` to the pubspec. +* Add `registerWith` to the Dart main class. + ## 2.0.0 * Migrate to null-safety. diff --git a/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart b/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart index e4fc24e78cff..5ec988216074 100644 --- a/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart +++ b/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart @@ -17,8 +17,15 @@ import 'package:shared_preferences_platform_interface/shared_preferences_platfor /// This class implements the `package:shared_preferences` functionality for Linux. class SharedPreferencesLinux extends SharedPreferencesStorePlatform { /// The default instance of [SharedPreferencesLinux] to use. + /// TODO(egarciad): Remove when the Dart plugin registrant lands on Flutter stable. + /// https://github.com/flutter/flutter/issues/81421 static SharedPreferencesLinux instance = SharedPreferencesLinux(); + /// Registers the Linux implementation. + static void registerWith() { + SharedPreferencesStorePlatform.instance = instance; + } + /// Local copy of preferences Map? _cachedPreferences; diff --git a/packages/shared_preferences/shared_preferences_linux/pubspec.yaml b/packages/shared_preferences/shared_preferences_linux/pubspec.yaml index a573b7cff438..d3bbc1e22363 100644 --- a/packages/shared_preferences/shared_preferences_linux/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_linux/pubspec.yaml @@ -1,10 +1,11 @@ name: shared_preferences_linux description: Linux implementation of the shared_preferences plugin -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences_linux flutter: plugin: + implements: shared_preferences platforms: linux: dartPluginClass: SharedPreferencesLinux diff --git a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart index 11e52dd6037f..62ec2b66c07a 100644 --- a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart +++ b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart @@ -6,16 +6,17 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart' as path; import 'package:path_provider_linux/path_provider_linux.dart'; import 'package:shared_preferences_linux/shared_preferences_linux.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart'; void main() { late MemoryFileSystem fs; + SharedPreferencesLinux.registerWith(); + setUp(() { fs = MemoryFileSystem.test(); }); - tearDown(() {}); - Future _getFilePath() async { final pathProvider = PathProviderLinux(); final directory = await pathProvider.getApplicationSupportPath(); @@ -38,6 +39,11 @@ void main() { return prefs; } + test('registered instance', () { + expect( + SharedPreferencesStorePlatform.instance, isA()); + }); + test('getAll', () async { await _writeTestFile('{"key1": "one", "key2": 2}'); var prefs = _getPreferences(); diff --git a/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md b/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md index 00c2f628796f..ac8dd2c4752b 100644 --- a/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md +++ b/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 + +* Add `implements` to the pubspec. + ## 2.0.0 * Migrate to null safety. diff --git a/packages/shared_preferences/shared_preferences_macos/pubspec.yaml b/packages/shared_preferences/shared_preferences_macos/pubspec.yaml index b1c883352452..6a5c8c006dbd 100644 --- a/packages/shared_preferences/shared_preferences_macos/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_macos/pubspec.yaml @@ -1,10 +1,11 @@ name: shared_preferences_macos description: macOS implementation of the shared_preferences plugin. -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences_macos flutter: plugin: + implements: shared_preferences platforms: macos: pluginClass: SharedPreferencesPlugin diff --git a/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md b/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md index 6fa4eb162083..34c48f37af48 100644 --- a/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md +++ b/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.1 + +* Add `implements` to pubspec.yaml. +* Add `registerWith` to the Dart main class. + ## 2.0.0 * Migrate to null-safety. diff --git a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart index 8bbda6ec139a..b8cd3702b837 100644 --- a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart +++ b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart @@ -16,8 +16,15 @@ import 'package:path_provider_windows/path_provider_windows.dart'; /// This class implements the `package:shared_preferences` functionality for Windows. class SharedPreferencesWindows extends SharedPreferencesStorePlatform { /// The default instance of [SharedPreferencesWindows] to use. + /// TODO(egarciad): Remove when the Dart plugin registrant lands on Flutter stable. + /// https://github.com/flutter/flutter/issues/81421 static SharedPreferencesWindows instance = SharedPreferencesWindows(); + /// Registers the Windows implementation. + static void registerWith() { + SharedPreferencesStorePlatform.instance = instance; + } + /// File system used to store to disk. Exposed for testing only. @visibleForTesting FileSystem fs = LocalFileSystem(); diff --git a/packages/shared_preferences/shared_preferences_windows/pubspec.yaml b/packages/shared_preferences/shared_preferences_windows/pubspec.yaml index cafb6b767045..4e8327cadb33 100644 --- a/packages/shared_preferences/shared_preferences_windows/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_windows/pubspec.yaml @@ -1,11 +1,11 @@ name: shared_preferences_windows description: Windows implementation of shared_preferences homepage: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences_windows -version: 2.0.0 - +version: 2.0.1 flutter: plugin: + implements: shared_preferences platforms: windows: dartPluginClass: SharedPreferencesWindows diff --git a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart index e577b9f76e48..6bb21b814e07 100644 --- a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart +++ b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart @@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart' as path; import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:path_provider_windows/path_provider_windows.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart'; import 'package:shared_preferences_windows/shared_preferences_windows.dart'; void main() { @@ -18,8 +19,6 @@ void main() { pathProvider = FakePathProviderWindows(); }); - tearDown(() {}); - Future _getFilePath() async { final directory = await pathProvider.getApplicationSupportPath(); return path.join(directory!, 'shared_preferences.json'); @@ -42,6 +41,12 @@ void main() { return prefs; } + test('registered instance', () { + SharedPreferencesWindows.registerWith(); + expect(SharedPreferencesStorePlatform.instance, + isA()); + }); + test('getAll', () async { await _writeTestFile('{"key1": "one", "key2": 2}'); var prefs = _getPreferences(); From 06350ef295a9469e15893fdef0bd8f9c1f3a095d Mon Sep 17 00:00:00 2001 From: hoonjae Date: Thu, 6 May 2021 10:51:01 +0900 Subject: [PATCH 6/6] feat: add an argument enableTakePictureWithMaxResolution --- .../lib/src/method_channel/method_channel_camera.dart | 3 +++ .../lib/src/platform_interface/camera_platform.dart | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart b/packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart index c6c363a56d65..a6a0dd305a6f 100644 --- a/packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart +++ b/packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart @@ -82,6 +82,7 @@ class MethodChannelCamera extends CameraPlatform { Future createCamera( CameraDescription cameraDescription, ResolutionPreset? resolutionPreset, { + bool enableTakePictureWithMaxResolution = false, bool enableAudio = false, }) async { try { @@ -91,6 +92,8 @@ class MethodChannelCamera extends CameraPlatform { 'resolutionPreset': resolutionPreset != null ? _serializeResolutionPreset(resolutionPreset) : null, + 'enableTakePictureWithMaxResolution': + enableTakePictureWithMaxResolution, 'enableAudio': enableAudio, }); diff --git a/packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart b/packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart index 4437d3b0593a..040716bb4439 100644 --- a/packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart +++ b/packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart @@ -54,6 +54,7 @@ abstract class CameraPlatform extends PlatformInterface { Future createCamera( CameraDescription cameraDescription, ResolutionPreset? resolutionPreset, { + bool enableTakePictureWithMaxResolution = false, bool enableAudio = false, }) { throw UnimplementedError('createCamera() is not implemented.');