Skip to content

Commit 48e03b8

Browse files
authored
Create android & web plugins (#15)
* create android & web plugins * apply `flutter format .`
1 parent 1a87bcf commit 48e03b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1200
-356
lines changed

android/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

android/build.gradle

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
group 'io.livekit.plugin'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
ext.kotlin_version = '1.3.50'
6+
repositories {
7+
google()
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
classpath 'com.android.tools.build:gradle:4.1.0'
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
}
15+
}
16+
17+
rootProject.allprojects {
18+
repositories {
19+
google()
20+
mavenCentral()
21+
}
22+
}
23+
24+
apply plugin: 'com.android.library'
25+
apply plugin: 'kotlin-android'
26+
27+
android {
28+
compileSdkVersion 30
29+
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_1_8
32+
targetCompatibility JavaVersion.VERSION_1_8
33+
}
34+
35+
kotlinOptions {
36+
jvmTarget = '1.8'
37+
}
38+
39+
sourceSets {
40+
main.java.srcDirs += 'src/main/kotlin'
41+
}
42+
43+
defaultConfig {
44+
minSdkVersion 16
45+
}
46+
}
47+
48+
dependencies {
49+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
50+
}

android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.gradle.jvmargs=-Xmx1536M
2+
android.useAndroidX=true
3+
android.enableJetifier=true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

android/settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'livekit'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.livekit.plugin">
3+
</manifest>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.livekit.plugin
2+
3+
import androidx.annotation.NonNull
4+
5+
import io.flutter.embedding.engine.plugins.FlutterPlugin
6+
import io.flutter.plugin.common.MethodCall
7+
import io.flutter.plugin.common.MethodChannel
8+
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
9+
import io.flutter.plugin.common.MethodChannel.Result
10+
11+
/** LiveKitPlugin */
12+
class LiveKitPlugin: FlutterPlugin, MethodCallHandler {
13+
/// The MethodChannel that will the communication between Flutter and native Android
14+
///
15+
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
16+
/// when the Flutter Engine is detached from the Activity
17+
private lateinit var channel : MethodChannel
18+
19+
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
20+
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "livekit_client")
21+
channel.setMethodCallHandler(this)
22+
}
23+
24+
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
25+
// no-op for now
26+
result.notImplemented()
27+
}
28+
29+
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
30+
channel.setMethodCallHandler(null)
31+
}
32+
}

example/lib/exts.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ extension LKExampleExt on BuildContext {
2424
context: this,
2525
builder: (ctx) => AlertDialog(
2626
title: const Text('UnPublish'),
27-
content: const Text('Would you like to un-publish your Camera & Mic ?'),
27+
content:
28+
const Text('Would you like to un-publish your Camera & Mic ?'),
2829
actions: [
2930
TextButton(
3031
onPressed: () => Navigator.pop(ctx, false),
@@ -92,7 +93,8 @@ extension LKExampleExt on BuildContext {
9293
context: this,
9394
builder: (ctx) => AlertDialog(
9495
title: const Text('Send data'),
95-
content: const Text('This will send a sample data to all participants in the room'),
96+
content: const Text(
97+
'This will send a sample data to all participants in the room'),
9698
actions: [
9799
TextButton(
98100
onPressed: () => Navigator.pop(ctx, false),

example/lib/pages/connect.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class _ConnectPageState extends State<ConnectPage> {
6565
// Save for next time
6666
await _writePrefs();
6767

68-
print('Connecting with url: ${_uriCtrl.text}, token: ${_tokenCtrl.text}...');
68+
print(
69+
'Connecting with url: ${_uriCtrl.text}, token: ${_tokenCtrl.text}...');
6970

7071
final room = await LiveKitClient.connect(
7172
_uriCtrl.text,
@@ -113,7 +114,8 @@ class _ConnectPageState extends State<ConnectPage> {
113114
decoration: BoxDecoration(
114115
color: Theme.of(context).cardColor,
115116
borderRadius: BorderRadius.circular(8),
116-
border: Border.all(color: Theme.of(context).colorScheme.secondary),
117+
border:
118+
Border.all(color: Theme.of(context).colorScheme.secondary),
117119
),
118120
constraints: const BoxConstraints(
119121
maxWidth: 320,

example/lib/pages/room.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class _RoomPageState extends State<RoomPage> {
5050

5151
void _setUpListeners() => _listener
5252
..on<RoomDisconnectedEvent>((_) async {
53-
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) => Navigator.pop(context));
53+
WidgetsBinding.instance
54+
?.addPostFrameCallback((timeStamp) => Navigator.pop(context));
5455
})
5556
..on<DataReceivedEvent>((event) {
5657
String decoded = 'Failed to decode';
@@ -120,7 +121,8 @@ class _RoomPageState extends State<RoomPage> {
120121
}
121122

122123
// joinedAt
123-
return a.joinedAt.millisecondsSinceEpoch - b.joinedAt.millisecondsSinceEpoch;
124+
return a.joinedAt.millisecondsSinceEpoch -
125+
b.joinedAt.millisecondsSinceEpoch;
124126
});
125127

126128
if (participants.length > 1) {
@@ -138,8 +140,9 @@ class _RoomPageState extends State<RoomPage> {
138140
body: Column(
139141
children: [
140142
Expanded(
141-
child:
142-
participants.isNotEmpty ? ParticipantWidget(participants.first) : Container()),
143+
child: participants.isNotEmpty
144+
? ParticipantWidget(participants.first)
145+
: Container()),
143146
SizedBox(
144147
height: 100,
145148
child: ListView.builder(
@@ -149,7 +152,8 @@ class _RoomPageState extends State<RoomPage> {
149152
width: 100,
150153
height: 100,
151154
padding: const EdgeInsets.all(2),
152-
child: ParticipantWidget(participants[index + 1], quality: VideoQuality.LOW),
155+
child: ParticipantWidget(participants[index + 1],
156+
quality: VideoQuality.LOW),
153157
),
154158
),
155159
),

0 commit comments

Comments
 (0)