Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
24a3e58c
Commit
24a3e58c
authored
May 09, 2017
by
Mikkel Nygaard Ravn
Committed by
GitHub
May 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Android plugin registry (#9715)
parent
aba60954
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
32 deletions
+21
-32
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+6
-12
.gitignore
...es/flutter_tools/templates/create/android.tmpl/.gitignore
+1
-1
MainActivity.java.tmpl
...n/java/com/yourcompany/projectName/MainActivity.java.tmpl
+7
-9
pluginClass.java.tmpl
...in/java/com/yourcompany/projectName/pluginClass.java.tmpl
+7
-10
No files found.
packages/flutter_tools/lib/src/plugins.dart
View file @
24a3e58c
...
...
@@ -77,26 +77,20 @@ void _writeFlutterPluginsList(String directory, List<Plugin> plugins) {
const
String
_androidPluginRegistryTemplate
=
'''package io.flutter.plugins;
import io.flutter.app.FlutterActivity;
{{#plugins}}
import io.flutter.plugin.common.PluginRegistry;
import {{package}}.{{class}};
{{/plugins}}
/**
* Generated file. Do not edit.
*/
public class PluginRegistry
{
public final class GeneratedPluginRegistrant {
public static void registerWith(PluginRegistry registry)
{
{{#plugins}}
public {{class}} {{name}}
;
{{class}}.registerWith(registry.registrarFor("{{package}}.{{class}}"))
;
{{/plugins}}
public void registerAll(FlutterActivity activity) {
{{#plugins}}
{{name}} = {{class}}.register(activity);
{{/plugins}}
}
}
}
'''
;
...
...
@@ -119,7 +113,7 @@ void _writeAndroidPluginRegistry(String directory, List<Plugin> plugins) {
final
Directory
registryDirectory
=
fs
.
directory
(
fs
.
path
.
join
(
javaSourcePath
,
'io'
,
'flutter'
,
'plugins'
));
registryDirectory
.
createSync
(
recursive:
true
);
final
File
registryFile
=
registryDirectory
.
childFile
(
'
PluginRegistry
.java'
);
final
File
registryFile
=
registryDirectory
.
childFile
(
'
GeneratedPluginRegistrant
.java'
);
registryFile
.
writeAsStringSync
(
pluginRegistry
);
}
...
...
packages/flutter_tools/templates/create/android.tmpl/.gitignore
View file @
24a3e58c
...
...
@@ -6,7 +6,7 @@
.DS_Store
/build
/captures
PluginRegistry
.java
GeneratedPluginRegistrant
.java
/gradle
/gradlew
...
...
packages/flutter_tools/templates/create/android.tmpl/app/src/main/java/com/yourcompany/projectName/MainActivity.java.tmpl
View file @
24a3e58c
package
{{
androidIdentifier
}};
import
android
.
os
.
Bundle
;
import
io
.
flutter
.
app
.
FlutterActivity
;
import
io
.
flutter
.
plugin
s
.
PluginRegistry
;
import
io
.
flutter
.
plugin
.
common
.
GeneratedPluginRegistrant
;
public
class
MainActivity
extends
FlutterActivity
{
PluginRegistry
pluginRegistry
;
@
Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
pluginRegistry
=
new
PluginRegistry
();
pluginRegistry
.
registerAll
(
this
);
}
@
Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
GeneratedPluginRegistrant
.
registerWith
(
this
);
}
}
packages/flutter_tools/templates/plugin/android.tmpl/src/main/java/com/yourcompany/projectName/pluginClass.java.tmpl
View file @
24a3e58c
package
{{
androidIdentifier
}};
import
io
.
flutter
.
app
.
FlutterActivity
;
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
;
/**
*
{{
pluginClass
}}
*/
public
class
{{
pluginClass
}}
implements
MethodCallHandler
{
private
FlutterActivity
activity
;
public
static
{{
pluginClass
}}
register
(
FlutterActivity
activity
)
{
return
new
{{
pluginClass
}}(
activity
);
}
private
{{
pluginClass
}}(
FlutterActivity
activity
)
{
this
.
activity
=
activity
;
new
MethodChannel
(
activity
.
getFlutterView
(),
"{{projectName}}"
).
setMethodCallHandler
(
this
);
/**
*
Plugin
registration
.
*/
public
static
void
registerWith
(
Registrar
registrar
)
{
final
MethodChannel
channel
=
new
MethodChannel
(
registrar
.
messenger
(),
"{{projectName}}"
);
channel
.
setMethodCallHandler
(
new
{{
pluginClass
}}());
}
@
Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment