From 50483699b5fcaa4153f2172a7d86abcdcf60ae8f Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 13 Sep 2021 13:51:25 +0200 Subject: [PATCH] Added group chat tutorial for Android with subject change & participants update --- .gitlab-ci-files/job-android.yml | 6 + android/kotlin/6-AdvancedChat/README.md | 4 +- android/kotlin/7-GroupChat/.gitignore | 15 + android/kotlin/7-GroupChat/.idea/$CACHE_FILE$ | 27 ++ android/kotlin/7-GroupChat/.idea/.gitignore | 3 + android/kotlin/7-GroupChat/.idea/.name | 1 + android/kotlin/7-GroupChat/.idea/compiler.xml | 6 + android/kotlin/7-GroupChat/.idea/gradle.xml | 22 ++ .../7-GroupChat/.idea/jarRepositories.xml | 30 ++ android/kotlin/7-GroupChat/.idea/misc.xml | 18 + android/kotlin/7-GroupChat/.idea/vcs.xml | 6 + android/kotlin/7-GroupChat/README.md | 6 + android/kotlin/7-GroupChat/app/.gitignore | 1 + android/kotlin/7-GroupChat/app/build.gradle | 50 +++ .../kotlin/7-GroupChat/app/proguard-rules.pro | 21 ++ .../app/src/main/AndroidManifest.xml | 24 ++ .../linphone/groupchat/GroupChatActivity.kt | 321 ++++++++++++++++++ .../drawable-v24/ic_launcher_foreground.xml | 30 ++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++ .../main/res/layout/group_chat_activity.xml | 175 ++++++++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3593 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5339 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2636 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 3388 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4926 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7472 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7909 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 11873 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10652 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 16570 bytes .../app/src/main/res/values-night/themes.xml | 16 + .../app/src/main/res/values/colors.xml | 15 + .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/themes.xml | 16 + android/kotlin/7-GroupChat/build.gradle | 26 ++ android/kotlin/7-GroupChat/gradle.properties | 21 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + android/kotlin/7-GroupChat/gradlew | 172 ++++++++++ android/kotlin/7-GroupChat/gradlew.bat | 84 +++++ android/kotlin/7-GroupChat/settings.gradle | 2 + 43 files changed, 1305 insertions(+), 2 deletions(-) create mode 100644 android/kotlin/7-GroupChat/.gitignore create mode 100644 android/kotlin/7-GroupChat/.idea/$CACHE_FILE$ create mode 100644 android/kotlin/7-GroupChat/.idea/.gitignore create mode 100644 android/kotlin/7-GroupChat/.idea/.name create mode 100644 android/kotlin/7-GroupChat/.idea/compiler.xml create mode 100644 android/kotlin/7-GroupChat/.idea/gradle.xml create mode 100644 android/kotlin/7-GroupChat/.idea/jarRepositories.xml create mode 100644 android/kotlin/7-GroupChat/.idea/misc.xml create mode 100644 android/kotlin/7-GroupChat/.idea/vcs.xml create mode 100644 android/kotlin/7-GroupChat/README.md create mode 100644 android/kotlin/7-GroupChat/app/.gitignore create mode 100644 android/kotlin/7-GroupChat/app/build.gradle create mode 100644 android/kotlin/7-GroupChat/app/proguard-rules.pro create mode 100644 android/kotlin/7-GroupChat/app/src/main/AndroidManifest.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/java/org/linphone/groupchat/GroupChatActivity.kt create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/layout/group_chat_activity.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/values-night/themes.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/values/colors.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/values/strings.xml create mode 100644 android/kotlin/7-GroupChat/app/src/main/res/values/themes.xml create mode 100644 android/kotlin/7-GroupChat/build.gradle create mode 100644 android/kotlin/7-GroupChat/gradle.properties create mode 100644 android/kotlin/7-GroupChat/gradle/wrapper/gradle-wrapper.jar create mode 100644 android/kotlin/7-GroupChat/gradle/wrapper/gradle-wrapper.properties create mode 100755 android/kotlin/7-GroupChat/gradlew create mode 100644 android/kotlin/7-GroupChat/gradlew.bat create mode 100644 android/kotlin/7-GroupChat/settings.gradle diff --git a/.gitlab-ci-files/job-android.yml b/.gitlab-ci-files/job-android.yml index 78b7eb9..5cf2980 100644 --- a/.gitlab-ci-files/job-android.yml +++ b/.gitlab-ci-files/job-android.yml @@ -34,6 +34,12 @@ job-android-advanced-chat: - cd android/kotlin/6-AdvancedChat/ - ./gradlew assembleRelease +job-android-group-chat: + extends: .job-android + script: + - cd android/kotlin/7-GroupChat/ + - ./gradlew assembleRelease + job-android-incoming-call: extends: .job-android script: diff --git a/android/kotlin/6-AdvancedChat/README.md b/android/kotlin/6-AdvancedChat/README.md index b81396f..47f7948 100644 --- a/android/kotlin/6-AdvancedChat/README.md +++ b/android/kotlin/6-AdvancedChat/README.md @@ -1,6 +1,6 @@ Advanced chat tutorial ==================== -This tutorial will demonstrate how to leverage on our own SIP server named [Flexisip](https://gitlab.linphone.org/BC/public/flexisip) and it's conference server to create group chats, use end-to-end encryption and send ephemeral messages. +This tutorial will demonstrate how to leverage on our own SIP server named [Flexisip](https://gitlab.linphone.org/BC/public/flexisip) and it's conference server to create end-to-end encrypted chat rooms and send ephemeral messages. -If you don't have deployed a flexisip server yet, you can create & use a free SIP account using our [free SIP service](https://subscribe.linphone.org/). \ No newline at end of file +If you don't have deployed a flexisip server yet, you can create & use a free SIP account using our [free SIP service](https://subscribe.linphone.org/). diff --git a/android/kotlin/7-GroupChat/.gitignore b/android/kotlin/7-GroupChat/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/android/kotlin/7-GroupChat/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/android/kotlin/7-GroupChat/.idea/$CACHE_FILE$ b/android/kotlin/7-GroupChat/.idea/$CACHE_FILE$ new file mode 100644 index 0000000..7da4bdc --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/$CACHE_FILE$ @@ -0,0 +1,27 @@ + + + + + + + + + Android + + + CorrectnessLintAndroid + + + Gradle + + + LintAndroid + + + Probable bugsGradle + + + + + + \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/.idea/.gitignore b/android/kotlin/7-GroupChat/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/android/kotlin/7-GroupChat/.idea/.name b/android/kotlin/7-GroupChat/.idea/.name new file mode 100644 index 0000000..5f28c14 --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/.name @@ -0,0 +1 @@ +Advanced Chat \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/.idea/compiler.xml b/android/kotlin/7-GroupChat/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/.idea/gradle.xml b/android/kotlin/7-GroupChat/.idea/gradle.xml new file mode 100644 index 0000000..7ef35fd --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/gradle.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/.idea/jarRepositories.xml b/android/kotlin/7-GroupChat/.idea/jarRepositories.xml new file mode 100644 index 0000000..d9f0af1 --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/.idea/misc.xml b/android/kotlin/7-GroupChat/.idea/misc.xml new file mode 100644 index 0000000..626b817 --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/misc.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/.idea/vcs.xml b/android/kotlin/7-GroupChat/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/android/kotlin/7-GroupChat/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/README.md b/android/kotlin/7-GroupChat/README.md new file mode 100644 index 0000000..1bbea38 --- /dev/null +++ b/android/kotlin/7-GroupChat/README.md @@ -0,0 +1,6 @@ +Group chat tutorial +==================== + +This tutorial will demonstrate how to leverage on our own SIP server named [Flexisip](https://gitlab.linphone.org/BC/public/flexisip) and it's conference server to create group chats. + +If you don't have deployed a flexisip server yet, you can create & use a free SIP account using our [free SIP service](https://subscribe.linphone.org/). \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/app/.gitignore b/android/kotlin/7-GroupChat/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/android/kotlin/7-GroupChat/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/app/build.gradle b/android/kotlin/7-GroupChat/app/build.gradle new file mode 100644 index 0000000..71cf59e --- /dev/null +++ b/android/kotlin/7-GroupChat/app/build.gradle @@ -0,0 +1,50 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "org.linphone.groupchat" + minSdkVersion 23 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +// We need to declare this repository to be able to use Liblinphone SDK +repositories { + maven { + url "https://linphone.org/maven_repository" + } +} + +dependencies { + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.2.1' + // Latest version is 5.0.x, using + to get the latest available + implementation 'org.linphone:linphone-sdk-android:5.0+' +} \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/app/proguard-rules.pro b/android/kotlin/7-GroupChat/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/android/kotlin/7-GroupChat/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/app/src/main/AndroidManifest.xml b/android/kotlin/7-GroupChat/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..18b1142 --- /dev/null +++ b/android/kotlin/7-GroupChat/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/kotlin/7-GroupChat/app/src/main/java/org/linphone/groupchat/GroupChatActivity.kt b/android/kotlin/7-GroupChat/app/src/main/java/org/linphone/groupchat/GroupChatActivity.kt new file mode 100644 index 0000000..c118bb1 --- /dev/null +++ b/android/kotlin/7-GroupChat/app/src/main/java/org/linphone/groupchat/GroupChatActivity.kt @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2010-2020 Belledonne Communications SARL. + * + * This file is part of linphone-android + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.linphone.groupchat + +import android.os.Bundle +import android.view.Gravity +import android.view.View +import android.widget.* +import androidx.appcompat.app.AppCompatActivity +import org.linphone.core.* +import java.io.File + +class GroupChatActivity: AppCompatActivity() { + private lateinit var core: Core + private var chatRoom: ChatRoom? = null + private var remoteAddresses = arrayListOf
() + + private val coreListener = object: CoreListenerStub() { + override fun onAccountRegistrationStateChanged(core: Core, account: Account, state: RegistrationState?, message: String) { + findViewById(R.id.registration_status).text = message + + if (state == RegistrationState.Failed) { + core.clearAllAuthInfo() + core.clearAccounts() + findViewById