Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade Flutter SDK 3.0 #685

Merged
merged 10 commits into from
May 20, 2022
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
35 changes: 28 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
integration_test_android:
name: Run Flutter Android Integration Tests
needs: flutter_codestyle_check
strategy:
matrix:
version: ['2.10.5', '3.0.0']
runs-on: macos-11
timeout-minutes: 60
env:
Expand All @@ -48,7 +51,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.5'
flutter-version: ${{ matrix.version }}
- name: run flutter android integration tests
uses: reactivecircus/android-emulator-runner@v2.21.0
with:
Expand All @@ -60,6 +63,9 @@ jobs:
integration_test_ios:
name: Run Flutter iOS Integration Tests
needs: flutter_codestyle_check
strategy:
matrix:
version: ['2.10.5', '3.0.0']
runs-on: macos-11
timeout-minutes: 60
env:
Expand All @@ -68,7 +74,7 @@ jobs:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.5'
flutter-version: ${{ matrix.version }}
- uses: futureware-tech/simulator-action@v1
with:
model: 'iPhone 13 Pro Max'
Expand All @@ -77,6 +83,9 @@ jobs:
integration_test_macos:
name: Run Flutter macOS Integration Tests
needs: flutter_codestyle_check
strategy:
matrix:
version: ['2.10.5', '3.0.0']
runs-on: macos-11
timeout-minutes: 60
env:
Expand All @@ -85,13 +94,16 @@ jobs:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.5'
flutter-version: ${{ matrix.version }}
- run: flutter config --enable-macos-desktop
- run: bash ci/run_flutter_macos_integration_test.sh

integration_test_windows:
name: Run Flutter Windows Integration Tests
needs: flutter_codestyle_check
strategy:
matrix:
version: ['2.10.5', '3.0.0']
runs-on: windows-2019
timeout-minutes: 60
env:
Expand All @@ -100,7 +112,7 @@ jobs:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.5'
flutter-version: ${{ matrix.version }}
- run: flutter config --enable-windows-desktop
- run: bash ci/run_flutter_macos_integration_test.sh

Expand Down Expand Up @@ -136,6 +148,9 @@ jobs:
build_android_windows:
name: Build Android on Windows
needs: flutter_codestyle_check
strategy:
matrix:
version: ['2.10.5', '3.0.0']
runs-on: windows-2019
steps:
- uses: actions/checkout@v1
Expand All @@ -144,7 +159,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.5'
flutter-version: ${{ matrix.version }}
- run: flutter pub get
- name: Run flutter build apk
run: flutter build apk
Expand All @@ -153,6 +168,9 @@ jobs:
build_android_ubuntu:
name: Build Android on Ubuntu
needs: flutter_codestyle_check
strategy:
matrix:
version: ['2.10.5', '3.0.0']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -161,7 +179,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.5'
flutter-version: ${{ matrix.version }}
- run: flutter pub get
- name: Run flutter build apk
run: flutter build apk
Expand All @@ -170,13 +188,16 @@ jobs:
build_ios:
name: Build iOS
needs: flutter_codestyle_check
strategy:
matrix:
version: ['2.10.5', '3.0.0']
runs-on: macos-11
timeout-minutes: 60
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.5'
flutter-version: ${{ matrix.version }}
- run: flutter pub get
- name: Run flutter build ios --no-codesign
run: flutter build ios --no-codesign
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ as [Custom Audio Source and Renderer](https://docs.agora.io/en/Video/custom_audi

Please note that you should not call the [RtcEngine.destroy](https://docs.agora.io/en/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#afb808cdc9025a77af7dd2bce98311bfe)/[AgoraRtcEngineKit.destroy](https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/destroy) function on Android/iOS code, because it will affect the [RtcEngine](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/lib/src/rtc_engine.dart) on the Flutter side. To see how to use `RtcEnginePlugin`, please check the custom audio source example:

Android: [CustomAudioPlugin.kt](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/android/app/src/main/kotlin/io/agora/agora_rtc_engine_example/custom_audio_source/CustomAudioPlugin.kt)
Android: [CustomCaptureAudioPlugin.kt](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/android/app/src/main/kotlin/io/agora/agora_rtc_engine_example/custom_capture_audio/CustomCaptureAudioPlugin.kt)

iOS: [CustmoAudioSourcePlugin.swift](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/ios/Runner/CustomAudioSource/CustmoAudioSourcePlugin.swift)
iOS: [CustomCaptureAudioPlugin.swift](https://github.com/AgoraIO/Agora-Flutter-SDK/blob/master/example/ios/Runner/CustomCaptureAudio/CustomCaptureAudioPlugin.swift)

## API Reference Resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,39 @@ private class PlatformViewApiTypeCallApiMethodCallHandler(
) : CallApiMethodCallHandler(irisRtcEngine) {
override fun callApi(apiType: Int, params: String?, sb: StringBuffer): Int {
platformView.updateView()
return irisRtcEngine.callApi(apiType, params, platformView.getIrisRenderView(), sb)
return platformView.getIrisRenderView()?.let {
irisRtcEngine.callApi(apiType, params, platformView.getIrisRenderView(), sb)
} ?: -1
}
}

// We should ensure not doing some leak in constructor
@Suppress("LeakingThis")
abstract class AgoraPlatformView(
private val context: Context,
private val context: Context?,
messenger: BinaryMessenger,
viewId: Int,
args: Map<*, *>?,
private val irisRtcEngine: IrisRtcEngine
irisRtcEngine: IrisRtcEngine
) : PlatformView, MethodChannel.MethodCallHandler {

private val parentView: FrameLayout = FrameLayout(context)
private var parentView: FrameLayout? = null

private var platformView: View
private var platformView: View? = null

private val channel: MethodChannel
private var channel: MethodChannel? = null

private val callApiMethodCallHandler: CallApiMethodCallHandler =
PlatformViewApiTypeCallApiMethodCallHandler(irisRtcEngine, this)
private var callApiMethodCallHandler: CallApiMethodCallHandler? = null

init {
platformView = createView(context.applicationContext)
parentView.addView(platformView)
parentView = context?.let { FrameLayout(context) }
platformView = createView(context)
parentView?.addView(platformView)

channel = MethodChannel(messenger, "${channelName}_$viewId")
channel.setMethodCallHandler(this)
channel?.setMethodCallHandler(this)

callApiMethodCallHandler = PlatformViewApiTypeCallApiMethodCallHandler(irisRtcEngine, this)

args?.apply {
for ((key, value) in entries) {
Expand All @@ -54,28 +58,27 @@ abstract class AgoraPlatformView(
}

fun updateView() {
parentView.removeAllViews()
platformView = createView(context.applicationContext)
parentView.addView(platformView)
parentView?.removeAllViews()
platformView = createView(context)
parentView?.addView(platformView)
}

abstract fun createView(context: Context): View
abstract fun createView(context: Context?): View?

protected abstract val channelName: String

fun getIrisRenderView(): View {
fun getIrisRenderView(): View? {
return platformView
}

override fun getView(): View {
override fun getView(): View? {
return parentView
}

override fun dispose() {
channel.setMethodCallHandler(null)
}

override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
callApiMethodCallHandler.onMethodCall(call, result)
callApiMethodCallHandler?.onMethodCall(call, result)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,6 @@ class AgoraRtcEnginePlugin : FlutterPlugin, MethodCallHandler, EventChannel.Stre
}
return@getAssetAbsolutePath
}
result.error(IllegalArgumentException::class.simpleName, null, null)
result.error(IllegalArgumentException::class.simpleName ?: "IllegalArgumentException", "The parameter should not be null", null)
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package io.agora.agora_rtc_engine

import android.content.Context
import android.view.SurfaceView
import android.view.View
import android.widget.FrameLayout
import io.agora.iris.rtc.IrisRtcEngine
import io.agora.rtc.RtcEngine
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.StandardMessageCodec
import io.flutter.plugin.platform.PlatformView
import io.flutter.plugin.platform.PlatformViewFactory
Expand All @@ -17,9 +13,9 @@ class AgoraSurfaceViewFactory(
private val messenger: BinaryMessenger,
private val irisRtcEngine: IrisRtcEngine
) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
override fun create(context: Context, viewId: Int, args: Any?): PlatformView {
override fun create(context: Context?, viewId: Int, args: Any?): PlatformView {
return AgoraPlatformViewSurface(
context.applicationContext,
context,
messenger,
viewId,
args as? Map<*, *>,
Expand All @@ -29,39 +25,17 @@ private val irisRtcEngine: IrisRtcEngine
}

class AgoraPlatformViewSurface(
context: Context,
context: Context?,
messenger: BinaryMessenger,
viewId: Int, args: Map<*, *>?,
irisRtcEngine: IrisRtcEngine
) : AgoraPlatformView(context, messenger, viewId, args, irisRtcEngine) {
override fun createView(context: Context): View {
return RtcEngine.CreateRendererView(context)
override fun createView(context: Context?): View? {
return context?.let {
RtcEngine.CreateTextureView(context)
}
}

override val channelName: String
get() = "agora_rtc_engine/surface_view"

override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
when (call.method) {
"setZOrderOnTop" -> {
val surfaceView = getIrisRenderView() as SurfaceView
val parentView = view as FrameLayout
parentView.removeView(surfaceView)
surfaceView.setZOrderOnTop((call.argument<Boolean>("onTop"))!!)
parentView.addView(surfaceView)
result.success(null)
}
"setZOrderMediaOverlay" -> {
val surfaceView = getIrisRenderView() as SurfaceView
val parentView = view as FrameLayout
parentView.removeView(surfaceView)
surfaceView.setZOrderMediaOverlay((call.argument<Boolean>("isMediaOverlay"))!!)
parentView.addView(surfaceView)
result.success(null)
}
else -> {
super.onMethodCall(call, result)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class AgoraTextureViewFactory(
private val irisRtcEngine: IrisRtcEngine
) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {

override fun create(context: Context, viewId: Int, args: Any?): PlatformView {
override fun create(context: Context?, viewId: Int, args: Any?): PlatformView {
return AgoraPlatformViewTexture(
context.applicationContext,
context,
messenger,
viewId,
args as? Map<*, *>,
Expand All @@ -26,14 +26,13 @@ class AgoraTextureViewFactory(
}

class AgoraPlatformViewTexture(
context: Context,
context: Context?,
messenger: BinaryMessenger,
viewId: Int, args: Map<*, *>?,
irisRtcEngine: IrisRtcEngine
) : AgoraPlatformView(context, messenger, viewId, args, irisRtcEngine) {
override fun createView(context: Context): View {

return RtcEngine.CreateTextureView(context)
override fun createView(context: Context?): View? {
return context?.let { RtcEngine.CreateTextureView(context) }
}

override val channelName: String
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ class _State extends State<EnableVirtualBackground> {
return Expanded(
child: Stack(
children: [
const rtc_local_view.SurfaceView(),
const rtc_local_view.SurfaceView(
),
Align(
alignment: Alignment.topLeft,
child: SingleChildScrollView(
Expand Down
1 change: 1 addition & 0 deletions example/lib/examples/advanced/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ final advanced = [
'widget': const EnableVirtualBackground()
},
{'name': 'MediaRecorder', 'widget': const MediaRecorder()},

];
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ class _State extends State<StreamMessage> {
width: 120,
child: rtc_remote_view.SurfaceView(
uid: uid,
channelId: config.channelId,
channelId: _channelIdController.text,
),
)
: SizedBox(
height: 120,
width: 120,
child: rtc_remote_view.TextureView(
uid: uid,
channelId: config.channelId,
channelId: _channelIdController.text,
),
));
}));
Expand Down
3 changes: 3 additions & 0 deletions example/linux/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
flutter/ephemeral
flutter/generated_plugins.cmake
flutter/generated_plugin_registrant.h
flutter/generated_plugin_registrant.cc
11 changes: 0 additions & 11 deletions example/linux/flutter/generated_plugin_registrant.cc

This file was deleted.

Loading