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

Update path provider to new plugin registration. #30

Merged
merged 4 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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/path-provider/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.2.0] - 2017-05-10

* Upgrade to new plugin registration. (https://groups.google.com/forum/#!topic/flutter-dev/zba1Ynf2OKM)

## [0.1.3] - 2017-05-09

* Upgrade Android SDK Build Tools to 25.0.3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@

package io.flutter.plugins.path_provider;

import io.flutter.app.FlutterActivity;
import android.app.Activity;

import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.util.PathUtils;


public class PathProviderPlugin implements MethodCallHandler {
private FlutterActivity activity;
private final Activity activity;


public static PathProviderPlugin register(FlutterActivity activity) {
return new PathProviderPlugin(activity);
public static void registerWith(Registrar registrar) {
MethodChannel channel =
new MethodChannel(registrar.messenger(), "plugins.flutter.io/path_provider");
PathProviderPlugin instance = new PathProviderPlugin(registrar.activity());
channel.setMethodCallHandler(instance);
}

private PathProviderPlugin(FlutterActivity activity) {
private PathProviderPlugin(Activity activity) {
this.activity = activity;
new MethodChannel(activity.getFlutterView(), "plugins.flutter.io/path_provider").
setMethodCallHandler(this);
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.PluginRegistry;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
PluginRegistry pluginRegistry;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pluginRegistry = new PluginRegistry();
pluginRegistry.registerAll(this);
GeneratedPluginRegistrant.registerWith(this);
}
}
294 changes: 153 additions & 141 deletions packages/path-provider/example/ios/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

/* Begin PBXFileReference section */
06B796751C0435964931B69B /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1498D2321E8E86230040F4C2 /* PluginRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PluginRegistry.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* PluginRegistry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PluginRegistry.m; sourceTree = "<group>"; };
2D9222461EC32A19007564B0 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
2D9222471EC32A19007564B0 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -117,15 +117,15 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
2D9222461EC32A19007564B0 /* GeneratedPluginRegistrant.h */,
2D9222471EC32A19007564B0 /* GeneratedPluginRegistrant.m */,
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
97C147021CF9000F007C117D /* Info.plist */,
97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* PluginRegistry.h */,
1498D2331E8E89220040F4C2 /* PluginRegistry.m */,
);
path = Runner;
sourceTree = "<group>";
Expand Down Expand Up @@ -292,7 +292,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
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";
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";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand All @@ -304,7 +304,7 @@
files = (
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
97C146F31CF9000F007C117D /* main.m in Sources */,
1498D2341E8E89220040F4C2 /* PluginRegistry.m in Sources */,
2D9222481EC32A19007564B0 /* GeneratedPluginRegistrant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
13 changes: 4 additions & 9 deletions packages/path-provider/example/ios/Runner/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include "AppDelegate.h"
#include "PluginRegistry.h"
#include "GeneratedPluginRegistrant.h"

@implementation AppDelegate {
PluginRegistry *plugins;
}
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
FlutterViewController *flutterController =
(FlutterViewController *)self.window.rootViewController;
plugins = [[PluginRegistry alloc] initWithController:flutterController];
return YES;
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Generated file. Do not edit.
//

#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h

#import <Flutter/Flutter.h>

#import "PathProviderPlugin.h"

@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end

#endif /* GeneratedPluginRegistrant_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Generated file. Do not edit.
//

#import "GeneratedPluginRegistrant.h"

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[PathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"PathProviderPlugin"]];
}

@end
20 changes: 0 additions & 20 deletions packages/path-provider/example/ios/Runner/PluginRegistry.h

This file was deleted.

16 changes: 0 additions & 16 deletions packages/path-provider/example/ios/Runner/PluginRegistry.m

This file was deleted.

3 changes: 1 addition & 2 deletions packages/path-provider/ios/Classes/PathProviderPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

#import <Flutter/Flutter.h>

@interface PathProviderPlugin : NSObject
- initWithController:(FlutterViewController *)controller;
@interface PathProviderPlugin : NSObject<FlutterPlugin>
@end
15 changes: 5 additions & 10 deletions packages/path-provider/ios/Classes/PathProviderPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@
return paths.firstObject;
}

@implementation PathProviderPlugin {
}
@implementation PathProviderPlugin

- (instancetype)initWithController:(FlutterViewController *)controller {
self = [super init];
if (self) {
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelWithName:@"plugins.flutter.io/path_provider"
binaryMessenger:controller];
binaryMessenger:registrar.messenger];
[channel setMethodCallHandler:^(FlutterMethodCall *call,
FlutterResult result) {
if ([@"getTemporaryDirectory" isEqualToString:call.method]) {
Expand All @@ -31,14 +28,12 @@ - (instancetype)initWithController:(FlutterViewController *)controller {
}
}];
}
return self;
}

- (NSString*)getTemporaryDirectory {
+ (NSString*)getTemporaryDirectory {
return GetDirectoryOfType(NSCachesDirectory);
}

- (NSString*)getApplicationDocumentsDirectory {
+ (NSString*)getApplicationDocumentsDirectory {
return GetDirectoryOfType(NSDocumentDirectory);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/path-provider/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: path_provider

version: 0.1.3
version: 0.2.0
description: A Flutter plugin for getting commonly used locations on the filesystem.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins
Expand All @@ -15,4 +15,4 @@ dependencies:
sdk: flutter

dev_dependencies:
test:
test: