Skip to content

Commit

Permalink
Compose (#381)
Browse files Browse the repository at this point in the history
* update podfile source to china

* update podfile source to china

* gitee sync test

* [Android] gitee sync >> use china repos.

* fix sync shell

* [Android]revert to use common repo url.

* update sync script.

* update sync script.

* update sync script.

* Add download agora SDK when executing pod install and modify dependencies

* gitee sync modify source url

* modify podfile file script

* modify podfile file script

* update download ijk and swiftlint

* update ijk download script

* iOS Adapt to RTC 4.3.1 version

* [windows] Adapt to 4.3.1 sdk and ajust examples.

* mac Adapt to RTC 4.3.1 version

* [windows]enable use_audio4

* [Android]Adapt to 4.3.1 sdk

* [Android][Audio]Adapt to 4.3.1 sdk

* Change way of using salt (#374)

* Change way of using salt

* Add macOS support

* [Windows]perfect screen parameter adjusting.

* [windows]change way of using salt.

* [Android]Renew beauty api and etc.

* add package_script

* [windows]fix case switch crash.

* [windows]fix release compile problem.

* [windows]change slider notify to NW_RELEASEDCAPTURE.

* [windows]show startCameraCapture error.

* [Android]Fix fragment back bug.

* [windows]fix original video bug (NMS-20350).

* fix  pip bug

* fix  crash  bug

* fix  volume bug

* fix  stutter bug

* [Android]Update beauty api and fix bug(NMS-20393)

* [Android]Fix beauty effect bug.

* [Android]Update gradle config.

* [Android]Update gradle config.

* [Android]Add pip mode demo.

* [windows]update ci.

* [windows]update ci.

* [windows]update ci.

* [windows]update ci 2.

* [windows]update ci 3.

* [Android][Compose]init project.

* [Android][Compose]adjust project construction, add setting and etc.

* [Android][Compose]add join channel auido,join channel video by token, and perfect codes.

* [Android][Compose]add rtmpstreaming case and fix bugs.

* [Android][Compose]add cases.

* [Android][Compose]add cases.

* [Android][Compose]add cases.

* [Android][Compose]add cases.

* [Android][Compose]add cert config and token.

---------

Co-authored-by: zhaoyongqiang <[email protected]>
Co-authored-by: sync2gitee <[email protected]>
Co-authored-by: Sihán Zhū <[email protected]>
  • Loading branch information
4 people committed May 24, 2024
1 parent 8cbd807 commit c25fa40
Show file tree
Hide file tree
Showing 91 changed files with 14,163 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/gitee-sync-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git config --global user.name "sync2gitee"
pwd
git remote -v

# change android maven to china repos
change android maven to china repos
sed -ie "s#google()#maven { url \"https\://maven.aliyun.com/repository/public\" }\n google()#g" Android/APIExample/settings.gradle
sed -ie "s#https://services.gradle.org/distributions#https://mirrors.cloud.tencent.com/gradle#g" Android/APIExample/gradle/wrapper/gradle-wrapper.properties
sed -ie "s#google()#maven { url \"https\://maven.aliyun.com/repository/public\" }\n google()#g" Android/APIExample-Audio/settings.gradle
Expand Down
15 changes: 15 additions & 0 deletions Android/APIExample-Compose/.gitignore
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Android/APIExample-Compose/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
93 changes: 93 additions & 0 deletions Android/APIExample-Compose/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import java.util.Properties

plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
}

android {
namespace = "io.agora.api.example.compose"
compileSdk = 34

defaultConfig {
applicationId = "io.agora.api.example.compose"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}

val properties = Properties()
properties.load(rootProject.file("local.properties").inputStream())
val AGORA_APP_ID = properties.getProperty("AGORA_APP_ID", "")
if(AGORA_APP_ID == ""){
throw GradleException("请在项目根目录下local.properties文件里正确配置:AGORA_APP_ID=<您的声网AppId>")
}
val AGORA_APP_CERT = properties.getProperty("AGORA_APP_CERT", "")
buildConfigField("String", "AGORA_APP_ID", "\"$AGORA_APP_ID\"")
buildConfigField("String", "AGORA_APP_CERT", "\"$AGORA_APP_CERT\"")
}

buildFeatures {
buildConfig = true
}
buildTypes {
release {
isMinifyEnabled = 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"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.datastore)
implementation(libs.androidx.datastore.preferences)
implementation(libs.agora.full.sdk)
implementation(libs.agora.full.screen.sharing)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
implementation(libs.androidx.material.icons.extended)
implementation(libs.okhttp)
implementation(libs.logging.interceptor)

}
21 changes: 21 additions & 0 deletions Android/APIExample-Compose/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.agora.api.example.compose

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("io.agora.api.example.compose", appContext.packageName)
}
}
39 changes: 39 additions & 0 deletions Android/APIExample-Compose/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.APIExampleCompose"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.APIExampleCompose">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Android/APIExample-Compose/app/src/main/assets/sample.yuv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.agora.api.example.compose

import androidx.compose.runtime.Composable
import io.agora.api.example.compose.ui.theme.APIExampleComposeTheme

@Composable
fun APIExampleApp(){
APIExampleComposeTheme {
NavGraph()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.agora.api.example.compose

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
APIExampleApp()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package io.agora.api.example.compose

import androidx.compose.runtime.Composable
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import io.agora.api.example.compose.model.Component
import io.agora.api.example.compose.model.Components
import io.agora.api.example.compose.model.Example
import io.agora.api.example.compose.ui.example.Example
import io.agora.api.example.compose.ui.home.Home
import io.agora.api.example.compose.ui.settings.Settings

@Composable
fun NavGraph() {
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = HomeRoute
) {
composable(HomeRoute) {
Home(
components = Components,
onExampleClick = { example, component -> navController.navigate(example.route(component)) },
onSettingClick = { navController.navigate(SettingsRoute) }
)
}
composable(SettingsRoute) {
Settings {
navController.popBackStack()
}
}
composable(
route = "$ExampleRoute/" +
"{$ComponentIdArgName}/" +
"{$ExampleIndexArgName}",
arguments = listOf(
navArgument(ComponentIdArgName) { type = NavType.IntType },
navArgument(ExampleIndexArgName) { type = NavType.IntType }
)
) { navBackStackEntry ->
val arguments = requireNotNull(navBackStackEntry.arguments) { "No arguments" }
val componentId = arguments.getInt(ComponentIdArgName)
val exampleIndex = arguments.getInt(ExampleIndexArgName)
val component = Components.first { component -> component.id == componentId }
val example = component.examples[exampleIndex]
Example(
example = example,
onBackClick = { navController.popBackStack() },
)
}
}

}

private fun Example.route(component: Component) =
"$ExampleRoute/${component.id}/${component.examples.indexOf(this)}"

private const val HomeRoute = "home"
private const val SettingsRoute = "settings"
private const val ExampleRoute = "example"
private const val ComponentIdArgName = "componentId"
private const val ExampleIndexArgName = "exampleIndex"
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.agora.api.example.compose.data

import io.agora.rtc2.RtcEngineConfig.AreaCode
import io.agora.rtc2.video.VideoEncoderConfiguration
import io.agora.rtc2.video.VideoEncoderConfiguration.FRAME_RATE
import io.agora.rtc2.video.VideoEncoderConfiguration.ORIENTATION_MODE
import io.agora.rtc2.video.VideoEncoderConfiguration.VideoDimensions

object SettingPreferences {

private var videoDimensions : VideoDimensions? = null
private var videoFrameRate : FRAME_RATE? = null
private var orientationMode: ORIENTATION_MODE? = null
private var area = AreaCode.AREA_CODE_GLOB

fun setVideoDimensions(dimensions: VideoDimensions?) {
videoDimensions = dimensions
}

fun getVideoDimensions(): VideoDimensions{
return videoDimensions ?: VideoEncoderConfiguration.VD_960x540
}

fun setVideoFrameRate(frameRate: FRAME_RATE?) {
videoFrameRate = frameRate
}

fun getVideoFrameRate(): FRAME_RATE{
return videoFrameRate ?: FRAME_RATE.FRAME_RATE_FPS_15
}

fun setOrientationMode(mode: ORIENTATION_MODE?) {
orientationMode = mode
}

fun getOrientationMode(): ORIENTATION_MODE {
return orientationMode ?: ORIENTATION_MODE.ORIENTATION_MODE_ADAPTIVE
}

fun setArea(area: Int) {
this.area = area
}

fun getArea(): Int {
return area
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.agora.api.example.compose.model

data class Component(
val id: Int,
val name: String,
val examples: List<Example>
)

val basicComponent = Component(
0,
"Basic",
examples = BasicExampleList
)

val advanceComponent = Component(
1,
"Advance",
examples = AdvanceExampleList
)

val Components = listOf(
basicComponent,
advanceComponent
)
Loading

0 comments on commit c25fa40

Please sign in to comment.