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

Commit

Permalink
review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
xster committed May 8, 2017
1 parent cdedeac commit 254455a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/share/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group 'com.yourcompany.share'
group 'io.flutter.plugins.share'
version '1.0-SNAPSHOT'

buildscript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
return;
}
final String text = (String) call.arguments;

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, text);
shareIntent.setType("text/plain");
context.startActivity(Intent.createChooser(shareIntent, null /* dialog title optional */));
share(text);
result.success(null);
} else {
result.error("UNKNOWN_METHOD", "Unknown share method called", null);
}
}

private void share(String text) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, text);
shareIntent.setType("text/plain");
context.startActivity(Intent.createChooser(shareIntent, null /* dialog title optional */));
}

}
3 changes: 0 additions & 3 deletions packages/share/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ android {

defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.yourcompany.share_example"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.share_example"
package="io.flutter.plugins.share_example"
android:versionCode="1"
android:versionName="0.0.1">

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

package io.flutter.plugins.share_example;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
Expand Down
4 changes: 4 additions & 0 deletions packages/share/example/ios/Runner/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>

Expand Down
4 changes: 4 additions & 0 deletions packages/share/example/ios/Runner/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "AppDelegate.h"
#include "PluginRegistry.h"

Expand Down
4 changes: 4 additions & 0 deletions packages/share/example/ios/Runner/main.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>
#import "AppDelegate.h"
Expand Down
17 changes: 11 additions & 6 deletions packages/share/ios/Classes/SharePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ - (instancetype)initWithController:
[shareChannel setMethodCallHandler:^(FlutterMethodCall *call,
FlutterResult result) {
if ([@"share" isEqualToString:call.method]) {
UIActivityViewController *activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[call.arguments]
applicationActivities:nil];
[controller presentViewController:activityViewController
animated:YES
completion:nil];
[self share:call.arguments withController:controller];
result(nil);
} else {
result([FlutterError errorWithCode:@"UNKNOWN_METHOD"
Expand All @@ -32,4 +27,14 @@ - (instancetype)initWithController:
}];
}


- (void)share:(id)sharedItems withController:(FlutterViewController *)controller {
UIActivityViewController *activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[sharedItems]
applicationActivities:nil];
[controller presentViewController:activityViewController
animated:YES
completion:nil];
}

@end

0 comments on commit 254455a

Please sign in to comment.