Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ private void init(AttributeSet attrs, int defStyle) {

private void initPainters() {
mWavePaint = new Paint();
mWavePaint.setColor(mWaveColor);// 画笔为color
mWavePaint.setStrokeWidth(waveStrokeWidth);// 设置画笔粗细
mWavePaint.setColor(mWaveColor);// Set paint color
mWavePaint.setStrokeWidth(waveStrokeWidth);// Set paint stroke width
mWavePaint.setAntiAlias(true);
mWavePaint.setFilterBitmap(true);
mWavePaint.setStrokeCap(Paint.Cap.ROUND);
mWavePaint.setStyle(Paint.Style.FILL);
Shader shader = new LinearGradient(0, 0, 1000, 0, 0xffffffff, 0xFFe850ee, Shader.TileMode.CLAMP);
mWavePaint.setShader(shader);
baseLinePaint = new Paint();
baseLinePaint.setColor(mBaseLineColor);// 画笔为color
baseLinePaint.setStrokeWidth(1f);// 设置画笔粗细
baseLinePaint.setColor(mBaseLineColor);// Set paint color
baseLinePaint.setStrokeWidth(1f);// Set paint stroke width
baseLinePaint.setAntiAlias(true);
baseLinePaint.setFilterBitmap(true);
baseLinePaint.setStyle(Paint.Style.FILL);
Expand Down Expand Up @@ -145,7 +145,7 @@ public void setMaxConstant(boolean maxConstant) {
}

/**
* 如果改变相应配置 需要刷新相应的paint设置
* If you change the corresponding configuration, you need to refresh the paint settings
*/
public void invalidateNow() {
initPainters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Executors
*
* @version 1.0
* @since 16/4/28 下午4:07
* @since 16/4/28 4:07 PM
*/
public class DefaultPoolExecutor extends ThreadPoolExecutor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @author zhilong <a href="mailto:[email protected]">Contact me.</a>
* @version 1.0
* @since 15/12/25 上午10:51
* @since 15/12/25 10:51 AM
*/
public class DefaultThreadFactory implements ThreadFactory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ public static void copyFilesFromAssets(Context context, String assetsPath, Strin
AssetManager assetManager = context.getAssets();
try {
File file = new File(storagePath);
if (!file.exists()) {//如果文件夹不存在,则创建新的文件夹
if (!file.exists()) {//If the folder does not exist, create a new folder
file.mkdirs();
}

// 获取assets目录下的所有文件及目录名
// Get all file and directory names under assets
String[] fileNames = assetManager.list(assetsPath);
if (fileNames.length > 0) {//如果是目录 apk
if (fileNames.length > 0) {//If it's a directory
for (String fileName : fileNames) {
if (!TextUtils.isEmpty(assetsPath)) {
temp = assetsPath + SEPARATOR + fileName;//补全assets资源路径
temp = assetsPath + SEPARATOR + fileName;//Complete assets resource path
}

String[] childFileNames = assetManager.list(temp);
if (!TextUtils.isEmpty(temp) && childFileNames.length > 0) {//判断是文件还是文件夹:如果是文件夹
if (!TextUtils.isEmpty(temp) && childFileNames.length > 0) {//Check if it's a file or folder: if it's a folder
copyFilesFromAssets(context, temp, storagePath + SEPARATOR + fileName);
} else {//如果是文件
} else {//If it's a file
InputStream inputStream = assetManager.open(temp);
readInputStream(storagePath + SEPARATOR + fileName, inputStream);
}
}
} else {//如果是文件 doc_test.txt或者apk/app_test.apk
} else {//If it's a file like doc_test.txt or apk/app_test.apk
InputStream inputStream = assetManager.open(assetsPath);
if (assetsPath.contains(SEPARATOR)) {//apk/app_test.apk
assetsPath = assetsPath.substring(assetsPath.lastIndexOf(SEPARATOR), assetsPath.length());
Expand All @@ -66,27 +66,27 @@ public static void copyFilesFromAssets(Context context, String assetsPath, Strin
}

/**
* 读取输入流中的数据写入输出流
* Read data from input stream and write to output stream
*
* @param storagePath 目标文件路径
* @param inputStream 输入流
* @param storagePath Target file path
* @param inputStream Input stream
*/
public static void readInputStream(String storagePath, InputStream inputStream) {
File file = new File(storagePath);
try {
if (!file.exists()) {
// 1.建立通道对象
// 1. Create channel object
FileOutputStream fos = new FileOutputStream(file);
// 2.定义存储空间
// 2. Define storage space
byte[] buffer = new byte[inputStream.available()];
// 3.开始读文件
// 3. Start reading file
int lenght = 0;
while ((lenght = inputStream.read(buffer)) != -1) {// 循环从输入流读取buffer字节
// 将Buffer中的数据写到outputStream对象中
while ((lenght = inputStream.read(buffer)) != -1) {// Read buffer bytes from input stream in a loop
// Write data from Buffer to outputStream object
fos.write(buffer, 0, lenght);
}
fos.flush();// 刷新缓冲区
// 4.关闭流
fos.flush();// Flush buffer
// 4. Close streams
fos.close();
inputStream.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static byte[] toWrappedI420(ByteBuffer bufferY,
return out;
}
/**
* I420转nv21
* Convert I420 to NV21
*/
public static byte[] I420ToNV21(byte[] data, int width, int height) {
byte[] ret = new byte[data.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:textSize="17sp"
android:text="此示例演示了如何使用SDK进行语音通话的功能。"/>
android:text="@string/the_example_feature_tips"/>

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/next"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@
<string name="audio_route_headset_typec">耳机(TypeC)</string>
<string name="audio_route_headset_bluetooth">蓝牙耳机</string>
<string name="notifications_enable_tip">请打开通知权限,防止后台录音中断</string>
<string name="the_example_feature_tips">此示例演示了如何使用SDK进行语音通话的功能。</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@
<string name="audio_route_headset_typec">headset(TypeC)</string>
<string name="audio_route_headset_bluetooth">bluetooth headset</string>
<string name="notifications_enable_tip">Please turn on notification permission to prevent background recording from being interrupted.</string>
<string name="the_example_feature_tips">This example demonstrates how to use the SDK to implement voice call functionality.</string>
</resources>
2 changes: 1 addition & 1 deletion Android/APIExample-Compose/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ android {
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>")
throw GradleException("Please configure correctly in the local.properties file in the project root directory: AGORA_APP_ID=<Your Agora AppId>")
}
val AGORA_APP_CERT = properties.getProperty("AGORA_APP_CERT", "")
buildConfigField("String", "AGORA_APP_ID", "\"$AGORA_APP_ID\"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fun ChannelEncryption() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()

val encryptionConfig = EncryptionConfig()
encryptionConfig.encryptionMode = encryptionMode
Expand All @@ -194,7 +194,7 @@ fun ChannelEncryption() {
}
} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.AudioGrid
import io.agora.api.example.compose.ui.common.AudioStatsInfo
Expand Down Expand Up @@ -160,7 +161,7 @@ fun CustomAudioRender() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val mediaOptions = ChannelMediaOptions()
mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
Expand All @@ -171,7 +172,7 @@ fun CustomAudioRender() {

} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fun CustomAudioSource() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
option.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
option.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
option.publishMicrophoneTrack = false
Expand All @@ -150,7 +150,7 @@ fun CustomAudioSource() {

} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}
CustomAudioSourceView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import io.agora.api.example.compose.BuildConfig
import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.TwoVideoView
Expand Down Expand Up @@ -134,7 +135,7 @@ fun CustomVideoRender() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val mediaOptions = ChannelMediaOptions()
mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
Expand All @@ -143,7 +144,7 @@ fun CustomVideoRender() {
}
} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import io.agora.api.example.compose.BuildConfig
import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.DropdownMenuRaw
Expand Down Expand Up @@ -171,7 +172,7 @@ fun CustomVideoSource() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val mediaOptions = ChannelMediaOptions()
mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
Expand All @@ -185,7 +186,7 @@ fun CustomVideoSource() {
externalVideoFramePusher.start()
} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ fun HostAcrossChannel() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val mediaOptions = ChannelMediaOptions()
mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
Expand All @@ -196,7 +196,7 @@ fun HostAcrossChannel() {
}
} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.AudioGrid
import io.agora.api.example.compose.ui.common.AudioStatsInfo
Expand Down Expand Up @@ -126,7 +127,7 @@ fun JoinChannelAudio() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val mediaOptions = ChannelMediaOptions()
mediaOptions.publishCameraTrack = false
mediaOptions.publishMicrophoneTrack = true
Expand All @@ -138,7 +139,7 @@ fun JoinChannelAudio() {

} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.VideoGrid
Expand Down Expand Up @@ -151,7 +152,7 @@ fun JoinChannelVideo() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val mediaOptions = ChannelMediaOptions()
mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
Expand All @@ -161,7 +162,7 @@ fun JoinChannelVideo() {

} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.agora.api.example.compose.BuildConfig
import io.agora.api.example.compose.R
import io.agora.api.example.compose.data.SettingPreferences
import io.agora.api.example.compose.ui.common.ChannelNameInput
import io.agora.api.example.compose.ui.common.VideoGrid
Expand Down Expand Up @@ -154,15 +155,15 @@ fun JoinChannelVideoToken() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val mediaOptions = ChannelMediaOptions()
mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
mediaOptions.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER
rtcEngine.joinChannel(token, channelName, 0, mediaOptions)

} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fun JoinMultiChannel() {
super.onLocalAudioStateChanged(state, reason)
if (state == Constants.LOCAL_AUDIO_STREAM_STATE_STOPPED) {
mainHandler.post {
Toast.makeText(context, "麦克风已关闭", Toast.LENGTH_SHORT).show()
Toast.makeText(context, "Microphone is turned off", Toast.LENGTH_SHORT).show()
}
}
}
Expand All @@ -174,7 +174,7 @@ fun JoinMultiChannel() {
val allGranted = grantedMap.values.all { it }
if (allGranted) {
// Permission is granted
Toast.makeText(context, "Permission Granted", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
val options = ChannelMediaOptions()
options.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE
Expand All @@ -196,7 +196,7 @@ fun JoinMultiChannel() {
}
} else {
// Permission is denied
Toast.makeText(context, "Permission Denied", Toast.LENGTH_LONG).show()
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show()
}
}

Expand Down
Loading
Loading