Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/share/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.2+2

* Fix iOS crash when setting subject to null.

## 0.6.2+1

* Specify explicit type for `invokeMethod`.
Expand Down
52 changes: 47 additions & 5 deletions packages/share/ios/Classes/SharePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,49 @@

static NSString *const PLATFORM_CHANNEL = @"plugins.flutter.io/share";

@interface ShareData : NSObject <UIActivityItemSource>

@property(readonly, nonatomic, copy) NSString *subject;
@property(readonly, nonatomic, copy) NSString *text;

- (instancetype)initWithSubject:(NSString *)subject text:(NSString *)text NS_DESIGNATED_INITIALIZER;

- (instancetype)init __attribute__((unavailable("Use initWithSubject:text: instead")));

@end

@implementation ShareData

- (instancetype)init {
[super doesNotRecognizeSelector:_cmd];
return nil;
}

- (instancetype)initWithSubject:(NSString *)subject text:(NSString *)text {
self = [super init];
if (self) {
_subject = subject;
_text = text;
}
return self;
}

- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
return @"";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious - should this be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://developer.apple.com/documentation/uikit/uiactivityitemsource/1620458-activityviewcontrollerplaceholde?language=objc

It should be one that the activity can handle otherwise you may get an activity with empty content.

So setting it to null/nil will result the activityController showing an empty content (manually tested)

}

- (id)activityViewController:(UIActivityViewController *)activityViewController
itemForActivityType:(UIActivityType)activityType {
return _text;
}

- (NSString *)activityViewController:(UIActivityViewController *)activityViewController
subjectForActivityType:(UIActivityType)activityType {
return [_subject isKindOfClass:NSNull.class] ? nil : _subject;
}

@end

@implementation FLTSharePlugin

+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
Expand All @@ -31,7 +74,7 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
NSNumber *originWidth = arguments[@"originWidth"];
NSNumber *originHeight = arguments[@"originHeight"];

CGRect originRect;
CGRect originRect = CGRectZero;
if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
originRect = CGRectMake([originX doubleValue], [originY doubleValue],
[originWidth doubleValue], [originHeight doubleValue]);
Expand All @@ -48,14 +91,13 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
}];
}

+ (void)share:(id)sharedItems
+ (void)share:(NSString *)shareText
subject:(NSString *)subject
withController:(UIViewController *)controller
atSource:(CGRect)origin {
ShareData *data = [[ShareData alloc] initWithSubject:subject text:shareText];
UIActivityViewController *activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[ sharedItems ]
applicationActivities:nil];
[activityViewController setValue:subject forKey:@"subject"];
[[UIActivityViewController alloc] initWithActivityItems:@[ data ] applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = controller.view;
if (!CGRectIsEmpty(origin)) {
activityViewController.popoverPresentationController.sourceRect = origin;
Expand Down
2 changes: 1 addition & 1 deletion packages/share/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for sharing content via the platform share UI, using
the ACTION_SEND intent on Android and UIActivityViewController on iOS.
author: Flutter Team <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/share
version: 0.6.2+1
version: 0.6.2+2

flutter:
plugin:
Expand Down
19 changes: 19 additions & 0 deletions packages/video_player/example/test_driver/video_player.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'dart:async';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops! How funny that this is included in this PR

import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:video_player/video_player.dart';

void main() {
final Completer<String> completer = Completer<String>();
enableFlutterDriverExtension(handler: (_) => completer.future);
tearDownAll(() => completer.complete(null));

group('VideoPlayer test driver', () {
test('VideoPlayer dispose without crash', () {
final VideoPlayerController controller =
VideoPlayerController.asset('assets/Butterfly-209.mp4');
controller.play();
controller.initialize();
});
});
}
10 changes: 10 additions & 0 deletions packages/video_player/example/test_driver/video_player_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void main() {
test('video_player', () async {
final FlutterDriver driver = await FlutterDriver.connect();
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
});
}