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

Commit 354ec39

Browse files
authored
Update path provider to new plugin registration. (#30)
1 parent 871aca4 commit 354ec39

File tree

14 files changed

+218
-235
lines changed

14 files changed

+218
-235
lines changed

packages/path-provider/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.2.0] - 2017-05-10
2+
3+
* Upgrade to new plugin registration. (https://groups.google.com/forum/#!topic/flutter-dev/zba1Ynf2OKM)
4+
15
## [0.1.3] - 2017-05-09
26

37
* Upgrade Android SDK Build Tools to 25.0.3.

packages/path-provider/android/src/main/java/io/flutter/plugins/path_provider/PathProviderPlugin.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@
44

55
package io.flutter.plugins.path_provider;
66

7-
import io.flutter.app.FlutterActivity;
7+
import android.app.Activity;
8+
89
import io.flutter.plugin.common.MethodChannel;
910
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
1011
import io.flutter.plugin.common.MethodChannel.Result;
1112
import io.flutter.plugin.common.MethodCall;
13+
import io.flutter.plugin.common.PluginRegistry.Registrar;
1214
import io.flutter.util.PathUtils;
1315

1416

1517
public class PathProviderPlugin implements MethodCallHandler {
16-
private FlutterActivity activity;
18+
private final Activity activity;
19+
1720

18-
public static PathProviderPlugin register(FlutterActivity activity) {
19-
return new PathProviderPlugin(activity);
21+
public static void registerWith(Registrar registrar) {
22+
MethodChannel channel =
23+
new MethodChannel(registrar.messenger(), "plugins.flutter.io/path_provider");
24+
PathProviderPlugin instance = new PathProviderPlugin(registrar.activity());
25+
channel.setMethodCallHandler(instance);
2026
}
2127

22-
private PathProviderPlugin(FlutterActivity activity) {
28+
private PathProviderPlugin(Activity activity) {
2329
this.activity = activity;
24-
new MethodChannel(activity.getFlutterView(), "plugins.flutter.io/path_provider").
25-
setMethodCallHandler(this);
2630
}
2731

2832
@Override

packages/path-provider/example/android/app/src/main/java/io/flutter/plugins/PluginRegistry.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/path-provider/example/android/app/src/main/java/io/flutter/plugins/path_provider_example/MainActivity.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
import android.os.Bundle;
44
import io.flutter.app.FlutterActivity;
5-
import io.flutter.plugins.PluginRegistry;
5+
import io.flutter.plugins.GeneratedPluginRegistrant;
66

77
public class MainActivity extends FlutterActivity {
8-
PluginRegistry pluginRegistry;
98

109
@Override
1110
protected void onCreate(Bundle savedInstanceState) {
1211
super.onCreate(savedInstanceState);
13-
pluginRegistry = new PluginRegistry();
14-
pluginRegistry.registerAll(this);
12+
GeneratedPluginRegistrant.registerWith(this);
1513
}
1614
}

packages/path-provider/example/ios/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 153 additions & 141 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/path-provider/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
0675671949C15323862C164B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06B796751C0435964931B69B /* Pods_Runner.framework */; };
11-
1498D2341E8E89220040F4C2 /* PluginRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* PluginRegistry.m */; };
11+
2D9222481EC32A19007564B0 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D9222471EC32A19007564B0 /* GeneratedPluginRegistrant.m */; };
1212
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1313
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
1414
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -41,8 +41,8 @@
4141

4242
/* Begin PBXFileReference section */
4343
06B796751C0435964931B69B /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
44-
1498D2321E8E86230040F4C2 /* PluginRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PluginRegistry.h; sourceTree = "<group>"; };
45-
1498D2331E8E89220040F4C2 /* PluginRegistry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PluginRegistry.m; sourceTree = "<group>"; };
44+
2D9222461EC32A19007564B0 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
45+
2D9222471EC32A19007564B0 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
4646
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4747
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
4848
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -117,15 +117,15 @@
117117
97C146F01CF9000F007C117D /* Runner */ = {
118118
isa = PBXGroup;
119119
children = (
120+
2D9222461EC32A19007564B0 /* GeneratedPluginRegistrant.h */,
121+
2D9222471EC32A19007564B0 /* GeneratedPluginRegistrant.m */,
120122
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
121123
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
122124
97C146FA1CF9000F007C117D /* Main.storyboard */,
123125
97C146FD1CF9000F007C117D /* Assets.xcassets */,
124126
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
125127
97C147021CF9000F007C117D /* Info.plist */,
126128
97C146F11CF9000F007C117D /* Supporting Files */,
127-
1498D2321E8E86230040F4C2 /* PluginRegistry.h */,
128-
1498D2331E8E89220040F4C2 /* PluginRegistry.m */,
129129
);
130130
path = Runner;
131131
sourceTree = "<group>";
@@ -292,7 +292,7 @@
292292
);
293293
runOnlyForDeploymentPostprocessing = 0;
294294
shellPath = /bin/sh;
295-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
295+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
296296
showEnvVarsInLog = 0;
297297
};
298298
/* End PBXShellScriptBuildPhase section */
@@ -304,7 +304,7 @@
304304
files = (
305305
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
306306
97C146F31CF9000F007C117D /* main.m in Sources */,
307-
1498D2341E8E89220040F4C2 /* PluginRegistry.m in Sources */,
307+
2D9222481EC32A19007564B0 /* GeneratedPluginRegistrant.m in Sources */,
308308
);
309309
runOnlyForDeploymentPostprocessing = 0;
310310
};
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
#include "AppDelegate.h"
2-
#include "PluginRegistry.h"
2+
#include "GeneratedPluginRegistrant.h"
33

4-
@implementation AppDelegate {
5-
PluginRegistry *plugins;
6-
}
4+
@implementation AppDelegate
75

86
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
9-
// Override point for customization after application launch.
10-
FlutterViewController *flutterController =
11-
(FlutterViewController *)self.window.rootViewController;
12-
plugins = [[PluginRegistry alloc] initWithController:flutterController];
13-
return YES;
7+
[GeneratedPluginRegistrant registerWithRegistry:self];
8+
return [super application:application didFinishLaunchingWithOptions:launchOptions];
149
}
1510

1611
@end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
#ifndef GeneratedPluginRegistrant_h
6+
#define GeneratedPluginRegistrant_h
7+
8+
#import <Flutter/Flutter.h>
9+
10+
#import "PathProviderPlugin.h"
11+
12+
@interface GeneratedPluginRegistrant : NSObject
13+
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
14+
@end
15+
16+
#endif /* GeneratedPluginRegistrant_h */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
#import "GeneratedPluginRegistrant.h"
6+
7+
@implementation GeneratedPluginRegistrant
8+
9+
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
10+
[PathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"PathProviderPlugin"]];
11+
}
12+
13+
@end

packages/path-provider/example/ios/Runner/PluginRegistry.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/path-provider/example/ios/Runner/PluginRegistry.m

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/path-provider/ios/Classes/PathProviderPlugin.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44

55
#import <Flutter/Flutter.h>
66

7-
@interface PathProviderPlugin : NSObject
8-
- initWithController:(FlutterViewController *)controller;
7+
@interface PathProviderPlugin : NSObject<FlutterPlugin>
98
@end

packages/path-provider/ios/Classes/PathProviderPlugin.m

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
return paths.firstObject;
1212
}
1313

14-
@implementation PathProviderPlugin {
15-
}
14+
@implementation PathProviderPlugin
1615

17-
- (instancetype)initWithController:(FlutterViewController *)controller {
18-
self = [super init];
19-
if (self) {
16+
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
2017
FlutterMethodChannel *channel = [FlutterMethodChannel
2118
methodChannelWithName:@"plugins.flutter.io/path_provider"
22-
binaryMessenger:controller];
19+
binaryMessenger:registrar.messenger];
2320
[channel setMethodCallHandler:^(FlutterMethodCall *call,
2421
FlutterResult result) {
2522
if ([@"getTemporaryDirectory" isEqualToString:call.method]) {
@@ -31,14 +28,12 @@ - (instancetype)initWithController:(FlutterViewController *)controller {
3128
}
3229
}];
3330
}
34-
return self;
35-
}
3631

37-
- (NSString*)getTemporaryDirectory {
32+
+ (NSString*)getTemporaryDirectory {
3833
return GetDirectoryOfType(NSCachesDirectory);
3934
}
4035

41-
- (NSString*)getApplicationDocumentsDirectory {
36+
+ (NSString*)getApplicationDocumentsDirectory {
4237
return GetDirectoryOfType(NSDocumentDirectory);
4338
}
4439

packages/path-provider/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: path_provider
22

3-
version: 0.1.3
3+
version: 0.2.0
44
description: A Flutter plugin for getting commonly used locations on the filesystem.
55
author: Flutter Team <[email protected]>
66
homepage: https://github.com/flutter/plugins
@@ -15,4 +15,4 @@ dependencies:
1515
sdk: flutter
1616

1717
dev_dependencies:
18-
test:
18+
test:

0 commit comments

Comments
 (0)