forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "[pigeon] Add an initial example app" (flutter#3785)"
This reverts commit 6b7f75b.
- Loading branch information
1 parent
dbab052
commit c097a49
Showing
117 changed files
with
4,360 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
channel: main | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
base_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
- platform: android | ||
create_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
base_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
- platform: ios | ||
create_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
base_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
- platform: linux | ||
create_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
base_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
- platform: macos | ||
create_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
base_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
- platform: web | ||
create_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
base_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
- platform: windows | ||
create_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
base_revision: a8354ff165eda6174ae423dca3b65c10fa952f4c | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# pigeon_example_app | ||
|
||
This demonstrates using Pigeon for platform communication directly in an | ||
application, rather than in a plugin. | ||
|
||
To update the generated code, run: | ||
```sh | ||
dart run pigeon --input pigeons/messages.dart | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
gradle-wrapper.jar | ||
/.gradle | ||
/captures/ | ||
/gradlew | ||
/gradlew.bat | ||
/local.properties | ||
GeneratedPluginRegistrant.java | ||
|
||
# Remember to never publicly share your keystore. | ||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app | ||
key.properties | ||
**/*.keystore | ||
**/*.jks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
def localProperties = new Properties() | ||
def localPropertiesFile = rootProject.file('local.properties') | ||
if (localPropertiesFile.exists()) { | ||
localPropertiesFile.withReader('UTF-8') { reader -> | ||
localProperties.load(reader) | ||
} | ||
} | ||
|
||
def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
if (flutterRoot == null) { | ||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
} | ||
|
||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
if (flutterVersionCode == null) { | ||
flutterVersionCode = '1' | ||
} | ||
|
||
def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
if (flutterVersionName == null) { | ||
flutterVersionName = '1.0' | ||
} | ||
|
||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
|
||
android { | ||
namespace "dev.flutter.pigeon_example_app" | ||
compileSdkVersion flutter.compileSdkVersion | ||
ndkVersion flutter.ndkVersion | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += 'src/main/kotlin' | ||
} | ||
|
||
defaultConfig { | ||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
applicationId "dev.flutter.pigeon_example_app" | ||
// You can update the following values to match your application needs. | ||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. | ||
minSdkVersion flutter.minSdkVersion | ||
targetSdkVersion flutter.targetSdkVersion | ||
versionCode flutterVersionCode.toInteger() | ||
versionName flutterVersionName | ||
} | ||
|
||
buildTypes { | ||
release { | ||
// TODO: Add your own signing config for the release build. | ||
// Signing with the debug keys for now, so `flutter run --release` works. | ||
signingConfig signingConfigs.debug | ||
} | ||
} | ||
} | ||
|
||
flutter { | ||
source '../..' | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/pigeon/example/app/android/app/src/debug/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- The INTERNET permission is required for development. Specifically, | ||
the Flutter tool needs it to communicate with the running application | ||
to allow setting breakpoints, to provide hot reload, etc. | ||
--> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
</manifest> |
33 changes: 33 additions & 0 deletions
33
packages/pigeon/example/app/android/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application | ||
android:label="pigeon_example_app" | ||
android:name="${applicationName}" | ||
android:icon="@mipmap/ic_launcher"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:launchMode="singleTop" | ||
android:theme="@style/LaunchTheme" | ||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
android:hardwareAccelerated="true" | ||
android:windowSoftInputMode="adjustResize"> | ||
<!-- Specifies an Android theme to apply to this Activity as soon as | ||
the Android process has started. This theme is visible to the user | ||
while the Flutter UI initializes. After that, this theme continues | ||
to determine the Window background behind the Flutter UI. --> | ||
<meta-data | ||
android:name="io.flutter.embedding.android.NormalTheme" | ||
android:resource="@style/NormalTheme" | ||
/> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<!-- Don't delete the meta-data below. | ||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> | ||
<meta-data | ||
android:name="flutterEmbedding" | ||
android:value="2" /> | ||
</application> | ||
</manifest> |
25 changes: 25 additions & 0 deletions
25
...on/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2013 The Flutter 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 dev.flutter.pigeon_example_app | ||
|
||
import ExampleHostApi | ||
import androidx.annotation.NonNull | ||
import io.flutter.embedding.android.FlutterActivity | ||
import io.flutter.embedding.engine.FlutterEngine | ||
|
||
private class PigeonApiImplementation: ExampleHostApi { | ||
override fun getHostLanguage(): String { | ||
return "Kotlin" | ||
} | ||
} | ||
|
||
class MainActivity: FlutterActivity() { | ||
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { | ||
super.configureFlutterEngine(flutterEngine) | ||
|
||
val api = PigeonApiImplementation() | ||
ExampleHostApi.setUp(flutterEngine.dartExecutor.binaryMessenger, api); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...geon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
// Autogenerated from Pigeon (v9.2.4), do not edit directly. | ||
// See also: https://pub.dev/packages/pigeon | ||
|
||
|
||
import android.util.Log | ||
import io.flutter.plugin.common.BasicMessageChannel | ||
import io.flutter.plugin.common.BinaryMessenger | ||
import io.flutter.plugin.common.MessageCodec | ||
import io.flutter.plugin.common.StandardMessageCodec | ||
import java.io.ByteArrayOutputStream | ||
import java.nio.ByteBuffer | ||
|
||
private fun wrapResult(result: Any?): List<Any?> { | ||
return listOf(result) | ||
} | ||
|
||
private fun wrapError(exception: Throwable): List<Any?> { | ||
if (exception is FlutterError) { | ||
return listOf( | ||
exception.code, | ||
exception.message, | ||
exception.details | ||
) | ||
} else { | ||
return listOf( | ||
exception.javaClass.simpleName, | ||
exception.toString(), | ||
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* Error class for passing custom error details to Flutter via a thrown PlatformException. | ||
* @property code The error code. | ||
* @property message The error message. | ||
* @property details The error details. Must be a datatype supported by the api codec. | ||
*/ | ||
class FlutterError ( | ||
val code: String, | ||
override val message: String? = null, | ||
val details: Any? = null | ||
) : Throwable() | ||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ | ||
interface ExampleHostApi { | ||
fun getHostLanguage(): String | ||
|
||
companion object { | ||
/** The codec used by ExampleHostApi. */ | ||
val codec: MessageCodec<Any?> by lazy { | ||
StandardMessageCodec() | ||
} | ||
/** Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. */ | ||
@Suppress("UNCHECKED_CAST") | ||
fun setUp(binaryMessenger: BinaryMessenger, api: ExampleHostApi?) { | ||
run { | ||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.ExampleHostApi.getHostLanguage", codec) | ||
if (api != null) { | ||
channel.setMessageHandler { _, reply -> | ||
var wrapped: List<Any?> | ||
try { | ||
wrapped = listOf<Any?>(api.getHostLanguage()) | ||
} catch (exception: Throwable) { | ||
wrapped = wrapError(exception) | ||
} | ||
reply.reply(wrapped) | ||
} | ||
} else { | ||
channel.setMessageHandler(null) | ||
} | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/pigeon/example/app/android/app/src/main/res/drawable-v21/launch_background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Modify this file to customize your launch splash screen --> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:drawable="?android:colorBackground" /> | ||
|
||
<!-- You can insert your own image assets here --> | ||
<!-- <item> | ||
<bitmap | ||
android:gravity="center" | ||
android:src="@mipmap/launch_image" /> | ||
</item> --> | ||
</layer-list> |
12 changes: 12 additions & 0 deletions
12
packages/pigeon/example/app/android/app/src/main/res/drawable/launch_background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Modify this file to customize your launch splash screen --> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:drawable="@android:color/white" /> | ||
|
||
<!-- You can insert your own image assets here --> | ||
<!-- <item> | ||
<bitmap | ||
android:gravity="center" | ||
android:src="@mipmap/launch_image" /> | ||
</item> --> | ||
</layer-list> |
Binary file added
BIN
+544 Bytes
packages/pigeon/example/app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+442 Bytes
packages/pigeon/example/app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+721 Bytes
packages/pigeon/example/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.01 KB
packages/pigeon/example/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.41 KB
...ages/pigeon/example/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.