Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 35d3f6c

Browse files
committed
review notes
1 parent cdedeac commit 35d3f6c

File tree

8 files changed

+38
-14
lines changed

8 files changed

+38
-14
lines changed

packages/share/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
group 'com.yourcompany.share'
1+
group 'io.flutter.plugins.share'
22
version '1.0-SNAPSHOT'
33

44
buildscript {

packages/share/android/src/main/java/io/flutter/plugins/share/SharePlugin.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
3838
return;
3939
}
4040
final String text = (String) call.arguments;
41-
42-
Intent shareIntent = new Intent();
43-
shareIntent.setAction(Intent.ACTION_SEND);
44-
shareIntent.putExtra(Intent.EXTRA_TEXT, text);
45-
shareIntent.setType("text/plain");
46-
context.startActivity(Intent.createChooser(shareIntent, null /* dialog title optional */));
41+
share(text);
4742
result.success(null);
4843
} else {
4944
result.error("UNKNOWN_METHOD", "Unknown share method called", null);
5045
}
5146
}
5247

48+
private void share(String text) {
49+
Intent shareIntent = new Intent();
50+
shareIntent.setAction(Intent.ACTION_SEND);
51+
shareIntent.putExtra(Intent.EXTRA_TEXT, text);
52+
shareIntent.setType("text/plain");
53+
context.startActivity(Intent.createChooser(shareIntent, null /* dialog title optional */));
54+
}
55+
5356
}

packages/share/example/android/app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.yourcompany.share_example"
2+
package="io.flutter.plugins.share_example"
33
android:versionCode="1"
44
android:versionName="0.0.1">
55

packages/share/example/android/app/src/main/java/com/yourcompany/share_example/MainActivity.java

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
package com.yourcompany.share_example;
26

37
import android.os.Bundle;

packages/share/example/ios/Runner/AppDelegate.h

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
#import <UIKit/UIKit.h>
26
#import <Flutter/Flutter.h>
37

packages/share/example/ios/Runner/AppDelegate.m

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
#include "AppDelegate.h"
26
#include "PluginRegistry.h"
37

packages/share/example/ios/Runner/main.m

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
#import <UIKit/UIKit.h>
26
#import <Flutter/Flutter.h>
37
#import "AppDelegate.h"

packages/share/ios/Classes/SharePlugin.m

+11-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ - (instancetype)initWithController:
1717
[shareChannel setMethodCallHandler:^(FlutterMethodCall *call,
1818
FlutterResult result) {
1919
if ([@"share" isEqualToString:call.method]) {
20-
UIActivityViewController *activityViewController =
21-
[[UIActivityViewController alloc] initWithActivityItems:@[call.arguments]
22-
applicationActivities:nil];
23-
[controller presentViewController:activityViewController
24-
animated:YES
25-
completion:nil];
20+
[self share:call.arguments];
2621
result(nil);
2722
} else {
2823
result([FlutterError errorWithCode:@"UNKNOWN_METHOD"
@@ -32,4 +27,14 @@ - (instancetype)initWithController:
3227
}];
3328
}
3429

30+
31+
- (void)share:(id)sharedItems {
32+
UIActivityViewController *activityViewController =
33+
[[UIActivityViewController alloc] initWithActivityItems:@[sharedItems]
34+
applicationActivities:nil];
35+
[controller presentViewController:activityViewController
36+
animated:YES
37+
completion:nil];
38+
}
39+
3540
@end

0 commit comments

Comments
 (0)