Skip to content

Swift UI #382

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

Merged
merged 23 commits into from
May 7, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 2 additions & 5 deletions .github/ci/build/build_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,11 @@ echo zip_name: %zip_name%

dir

echo off
REM curl --silent %sdk_url% ./
python %WORKSPACE%\\artifactory_utils.py --action=download_file --file=%sdk_url%
curl %sdk_url% -o %zip_name%
REM python %WORKSPACE%\\artifactory_utils.py --action=download_file --file=%sdk_url%
7z x ./%zip_name% -y
echo on

dir

rmdir /S /Q Agora_Native_SDK_for_Windows_FULL\demo
del /F /Q Agora_Native_SDK_for_Windows_FULL\commits
del /F /Q Agora_Native_SDK_for_Windows_FULL\package_size_report.txt
Expand Down
6 changes: 4 additions & 2 deletions .github/ci/build/modify_podfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ def modfiy(path):
contents = []
for num, line in enumerate(file):
if "pod 'Agora" in line:
line = '\t'+"pod 'sdk', :path => '../../sdk.podspec'"
line = '\t'+"pod 'sdk', :path => '../../sdk.podspec'" + "\n"
elif "pod 'sdk" in line:
line = ""
elif 'sh .download_script' in line:
line = line.replace('true', 'false') + "\n"
contents.append(line)
file.close()

with open(path, 'w', encoding='utf-8') as fw:
for content in contents:
fw.write(content + "\n")
fw.write(content)
fw.close()


Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/gitee-sync-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ 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
sed -ie "s#https://services.gradle.org/distributions#https://mirrors.cloud.tencent.com/gradle#g" Android/APIExample-Audio/gradle/wrapper/gradle-wrapper.properties
git add Android/APIExample/settings.gradle Android/APIExample/gradle/wrapper/gradle-wrapper.properties Android/APIExample-Audio/settings.gradle Android/APIExample-Audio/gradle/wrapper/gradle-wrapper.properties
git commit -m '[Android] gitee sync >> use china repos.'

# change iOS Podfile to china repos
python3 .github/workflows/modify_podfile.py iOS/APIExample/Podfile
python3 .github/workflows/modify_podfile.py iOS/APIExample-Audio/Podfile
python3 .github/workflows/modify_podfile.py iOS/APIExample-OC/Podfile
python3 .github/workflows/modify_podfile.py macOS/Podfile

# sed -ie '1s#^#source "https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git"\n#' iOS/APIExample/Podfile
# sed -ie '1s#^#source "https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git"\n#' iOS/APIExample-Audio/Podfile
# sed -ie '1s#^#source "https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git"\n#' iOS/APIExample-OC/Podfile
# sed -ie '1s#^#source "https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git"\n#' macOS/Podfile
git add iOS/APIExample/Podfile iOS/APIExample-Audio/Podfile iOS/APIExample-OC/Podfile macOS/Podfile
git commit -m '[iOS] gitee sync >> use china repos.'

git branch
git status
git push gitee
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/gitee-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: github.actor != 'dependabot[bot]'
steps:
- name: Gitee sync repo
uses: xgfd3/hub-mirror-action@v1.0
uses: xgfd3/hub-mirror-action@v1.4
with:
src: github/AgoraIO
dst: gitee/agoraio-community
Expand All @@ -25,4 +25,5 @@ jobs:
dst_token: ${{ secrets.GITEE_PRIVATE_TOKEN }}
force_update: true
account_type: org
shell_path: ./.github/workflows/gitee-sync-shell.sh
shell_path: ./.github/workflows/gitee-sync-shell.sh
github_ref: ${{ github.ref }}
34 changes: 34 additions & 0 deletions .github/workflows/modify_podfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os, sys

def modfiy(path):
with open(path, 'r', encoding='utf-8') as file:
contents = []
for num, line in enumerate(file):
if "pod 'Agora" in line:
line = '\t'+"pod 'sdk', :path => 'sdk.podspec'" + "\n"
elif "pod 'sdk" in line:
line = ""
elif "pod 'Floaty" in line:
line = '\t'+"pod 'Floaty', :git => 'https://gitee.com/shengwang-dependencies/Floaty.git'" + "\n"
elif "pod 'AGEVideoLayout" in line:
line = '\t'+"pod 'AGEVideoLayout', :git => 'https://gitee.com/shengwang-dependencies/AGEVideoLayout.git'" + "\n"
elif "pod 'CocoaAsyncSocket" in line:
line = '\t'+"pod 'CocoaAsyncSocket', :git => 'https://gitee.com/shengwang-dependencies/CocoaAsyncSocket.git'" + "\n"
elif "pod 'SwiftLint" in line:
line = '\t'+"pod 'SwiftLint', :git => 'https://gitee.com/shengwang-dependencies/SwiftLint', :commit => '1067113303c134ef472a71b30d21e5350de7889d'" + "\n"
elif "pod 'ijkplayer" in line:
line = '\t'+"pod 'ijkplayer', :path => 'ijkplayer.podspec'" + "\n"
elif 'sh .download_script' in line:
line = line.replace('#', '').replace('false', 'true')
contents.append(line)
file.close()

with open(path, 'w', encoding='utf-8') as fw:
for content in contents:
fw.write(content)
fw.close()


if __name__ == '__main__':
path = sys.argv[1:][0]
modfiy(path.strip())
2 changes: 1 addition & 1 deletion Android/APIExample-Audio/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
implementation fileTree(dir: "${localSdkPath}", include: ['*.jar', '*.aar'])
}
else{
def agora_sdk_version = "4.3.0"
def agora_sdk_version = "4.3.1"
// case 1: full single lib with voice only
implementation "io.agora.rtc:voice-sdk:${agora_sdk_version}"
// case 2: partial libs with voice only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
return NavigationUI.navigateUp(navController, appBarConfiguration)
|| super.onSupportNavigateUp();
onBackPressed();
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void handleOnBackPressed() {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handler = new Handler(Looper.getMainLooper());
requireActivity().getOnBackPressedDispatcher().addCallback(onBackPressedCallback);
requireActivity().getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public boolean onEarMonitoringAudioFrame(int type, int samplesPerChannel, int by
}

@Override
public boolean onPlaybackAudioFrameBeforeMixing(String channel, int uid, int audioFrameType, int samples, int bytesPerSample, int channels, int samplesPerSec, ByteBuffer byteBuffer, long renderTimeMs, int bufferLength) {
public boolean onPlaybackAudioFrameBeforeMixing(String channelId, int uid, int type, int samplesPerChannel, int bytesPerSample, int channels, int samplesPerSec, ByteBuffer buffer, long renderTimeMs, int avsync_type, int rtpTimestamp) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.3.3-bin.zip
2 changes: 2 additions & 0 deletions Android/APIExample-Audio/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pluginManagement {
repositories {
maven { url "https://maven.aliyun.com/repository/public" }
google()
mavenCentral()
gradlePluginPortal()
Expand All @@ -8,6 +9,7 @@ pluginManagement {
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven { url "https://maven.aliyun.com/repository/public" }
google()
mavenCentral()
maven { url "https://jitpack.io" }
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()
}
}
Loading
Loading