Skip to content

Commit a0eb32e

Browse files
author
zhaoyongqiang
committed
Merge branch 'dev/4.1.0' of github.com:AgoraIO/API-Examples into dev/4.1.0
2 parents cf4c810 + 883ca0b commit a0eb32e

127 files changed

Lines changed: 3149 additions & 1694 deletions

File tree

Some content is hidden

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

.github/ci/build/build_android.groovy

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildUtils = new agora.build.BuildUtils()
77

88
compileConfig = [
99
"sourceDir": "api-examples",
10-
"docker": "null",
10+
"docker": "hub.agoralab.co/server/apiexample_build_android:latest",
1111
"non-publish": [
1212
"command": "./.github/ci/build/build_android.sh",
1313
"extraArgs": "",
@@ -19,9 +19,6 @@ compileConfig = [
1919
]
2020

2121
def doBuild(buildVariables) {
22-
preCommand = '''
23-
export ANDROID_NDK_ROOT="${HOME}/Library/Android/android-ndk-r21e"
24-
'''
2522
type = params.Package_Publish ? "publish" : "non-publish"
2623
command = compileConfig.get(type).command
2724
preCommand = compileConfig.get(type).get("preCommand", "")
@@ -56,4 +53,4 @@ def doPublish(buildVariables) {
5653
sh "rm -rf *.zip || true"
5754
}
5855

59-
pipelineLoad(this, "ApiExample", "build", "android", "apiexample_linux")
56+
pipelineLoad(this, "ApiExample", "build", "android", "apiexample_linux")

.github/ci/build/build_android.sh

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,18 @@ echo short_version: $short_version
5050
echo pwd: `pwd`
5151
echo sdk_url: $sdk_url
5252

53+
ls ~/.gradle || (mkdir -p /tmp/.gradle && ln -s /tmp/.gradle ~/.gradle && touch ~/.gradle/ln_$(date "+%y%m%d%H") && ls ~/.gradle)
54+
5355
zip_name=${sdk_url##*/}
5456
echo zip_name: $zip_name
5557

56-
python3 $WORKSPACE/artifactory_utils.py --action=download_file --file=$sdk_url
57-
7za x ./$zip_name -y
58+
# env LC_ALL=en_US.UTF-8 python3 $WORKSPACE/artifactory_utils.py --action=download_file --file=$sdk_url || exit 1
59+
curl -o $zip_name $sdk_url || exit 1
60+
7za x ./$zip_name -y > log.txt
5861

59-
unzip_name=`ls -S -d */ | grep Agora`
62+
unzip_name=`ls -S -d */ | grep Agora | sed 's/\///g'`
6063
echo unzip_name: $unzip_name
6164

62-
#mv $unzip_name/rtc/** $unzip_name
63-
#rm -rf $unzip_name/rtc
64-
#rm -rf ./$unzip_name/bin
65-
#rm -rf ./$unzip_name/demo
66-
#rm ./$unzip_name/commits
67-
#rm ./$unzip_name/package_size_report.txt
68-
#mkdir ./$unzip_name/samples
69-
#mkdir ./$unzip_name/samples/API-example
70-
#cp -rf ./Android/APIExample$(echo $sdk_url | cut -d "/" -f 9 | grep audio_only | cut -d "_" -f 1 | sed -e 's/a/-A/g')/** ./$unzip_name/samples/API-example
71-
7265
rm -rf ./$unzip_name/rtc/bin
7366
rm -rf ./$unzip_name/rtc/demo
7467
rm ./$unzip_name/rtc/commits
@@ -77,31 +70,19 @@ mkdir ./$unzip_name/rtc/samples
7770
mkdir ./$unzip_name/rtc/samples/API-example
7871
cp -rf ./Android/APIExample$(echo $sdk_url | cut -d "/" -f 9 | grep audio_only | cut -d "_" -f 1 | sed -e 's/a/-A/g')/** ./$unzip_name/rtc/samples/API-example
7972

80-
7za a -tzip result.zip -r $unzip_name
73+
7za a -tzip result.zip -r $unzip_name > log.txt
8174
mv result.zip $WORKSPACE/withAPIExample_$(date "+%d%H%M")_$zip_name
8275

8376
# install android sdk
8477
which java
8578
java --version
86-
echo ${ANDROID_HOME}
87-
ls -al ${ANDROID_HOME}/*
88-
89-
cd ./$unzip_name/samples/
90-
mkdir AndroidSDK
91-
export ANDROID_HOME=$(pwd)/AndroidSDK
92-
cd -
93-
cd ${ANDROID_HOME}
94-
wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
95-
unzip commandlinetools-linux-8512546_latest.zip
96-
export PATH=$(pwd)/cmdline-tools/bin:$PATH
97-
yes | sdkmanager --licenses --sdk_root=${ANDROID_HOME}
98-
yes | sdkmanager "platform-tools" "cmake;3.10.2.4988404" "platforms;android-32" "build-tools;32.0.0" --sdk_root=${ANDROID_HOME}
99-
cd -
79+
source ~/.bashrc
80+
export ANDROID_HOME=/usr/lib/android_sdk
81+
echo ANDROID_HOME: $ANDROID_HOME
10082

10183
# compile apk
102-
cd ./$unzip_name/samples/API-example
84+
cd ./$unzip_name/rtc/samples/API-example
10385
pwd
104-
ls -al
10586

10687
## config appId
10788
sed -i -e "s#YOUR APP ID#${APP_ID}#g" app/src/main/res/values/string_configs.xml
@@ -115,17 +96,17 @@ sed -i -e "s#simpleFilter = false#simpleFilter = true#g" gradle.properties
11596
mkdir -p agora-simple-filter/src/main/agoraLibs
11697
cp -r ../../sdk/arm64-v8a agora-simple-filter/src/main/agoraLibs/
11798
cp -r ../../sdk/armeabi-v7a agora-simple-filter/src/main/agoraLibs/
118-
wget https://agora-adc-artifacts.s3.cn-north-1.amazonaws.com.cn/androidLibs/opencv4.zip
99+
curl -o opencv4.zip https://agora-adc-artifacts.s3.cn-north-1.amazonaws.com.cn/androidLibs/opencv4.zip
119100
unzip opencv4.zip
120-
mkdir -p agora-simple-filter/src/main/jniLibs2
121-
mv arm64-v8a agora-simple-filter/src/main/jniLibs2
122-
mv armeabi-v7a agora-simple-filter/src/main/jniLibs2
123-
sed -i -e "s#jniLibs/#jniLibs2/#g" agora-simple-filter/src/main/cpp/CMakeLists.txt
101+
mkdir -p agora-simple-filter/src/main/libs
102+
mv arm64-v8a agora-simple-filter/src/main/libs
103+
mv armeabi-v7a agora-simple-filter/src/main/libs
104+
sed -i -e "s#jniLibs/#libs/#g" agora-simple-filter/src/main/cpp/CMakeLists.txt
124105

125-
./gradlew clean
126-
./gradlew :app:assembleDebug
106+
./gradlew clean || exit 1
107+
./gradlew :app:assembleDebug || exit 1
127108
cp app/build/outputs/apk/debug/app-debug.apk ./APIExample_Android_$(date "+%y%m%d%H").apk
128-
7za a -tzip result.zip -r *.apk
109+
7za a -tzip result.zip -r *.apk > log.txt
129110
mv result.zip $WORKSPACE/APIExample_Android$(echo $sdk_url | cut -d "/" -f 9 | grep audio_only | cut -d "_" -f 1 | sed -e 's/a/_A/g')_$(date "+%y%m%d%H%M")_apk.zip
130111
ls $WORKSPACE
131112
cd -

Android/APIExample-Audio/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
android:icon="@mipmap/ic_launcher"
2020
android:label="@string/app_name"
2121
android:requestLegacyExternalStorage="true"
22-
android:roundIcon="@mipmap/ic_launcher_round"
2322
android:supportsRtl="true"
2423
android:theme="@style/AppTheme">
2524

@@ -28,6 +27,7 @@
2827
android:configChanges="keyboardHidden|screenSize|orientation"
2928
android:label="@string/app_name"
3029
android:screenOrientation="portrait"
30+
android:launchMode="singleTop"
3131
android:exported="true">
3232
<intent-filter>
3333
<action android:name="android.intent.action.MAIN" />
@@ -40,6 +40,7 @@
4040
android:name=".SettingActivity"
4141
android:label="@string/setting"
4242
android:parentActivityName=".MainActivity"
43+
android:windowSoftInputMode="stateAlwaysHidden"
4344
android:screenOrientation="portrait" />
4445

4546
</application>

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/SettingActivity.java

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import android.os.Bundle;
44
import android.view.LayoutInflater;
5+
import android.view.Menu;
56
import android.view.MenuItem;
6-
import android.view.View;
7-
import android.widget.AdapterView;
87

8+
import androidx.annotation.NonNull;
99
import androidx.annotation.Nullable;
1010
import androidx.appcompat.app.AppCompatActivity;
1111

@@ -16,18 +16,18 @@
1616
/**
1717
* @author cjw
1818
*/
19-
public class SettingActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
19+
public class SettingActivity extends AppCompatActivity{
2020
private static final String TAG = SettingActivity.class.getSimpleName();
2121

2222
private ActivitySettingLayoutBinding mBinding;
23+
private MenuItem saveMenu;
2324

2425
@Override
2526
protected void onCreate(@Nullable Bundle savedInstanceState) {
2627
super.onCreate(savedInstanceState);
2728
mBinding = ActivitySettingLayoutBinding.inflate(LayoutInflater.from(this));
2829
setContentView(mBinding.getRoot());
2930
mBinding.sdkVersion.setText(String.format(getString(R.string.sdkversion1), RtcEngine.getSdkVersion()));
30-
mBinding.areaSpinner.setOnItemSelectedListener(this);
3131
fetchGlobalSettings();
3232
}
3333

@@ -57,37 +57,28 @@ private void fetchGlobalSettings(){
5757
}
5858

5959
@Override
60-
public void onBackPressed() {
61-
super.onBackPressed();
62-
63-
GlobalSettings globalSettings = ((MainApplication)getApplication()).getGlobalSettings();
64-
globalSettings.privateCloudIp = mBinding.privateCloudLayout.etIpAddress.getText().toString();
65-
globalSettings.privateCloudLogReportEnable = mBinding.privateCloudLayout.swLogReport.isChecked();
66-
globalSettings.privateCloudLogServerDomain = mBinding.privateCloudLayout.etLogServerDomain.getText().toString();
67-
globalSettings.privateCloudLogServerPort = Integer.parseInt(mBinding.privateCloudLayout.etLogServerPort.getText().toString());
68-
globalSettings.privateCloudLogServerPath = mBinding.privateCloudLayout.etLogServerPath.getText().toString();
69-
globalSettings.privateCloudUseHttps = mBinding.privateCloudLayout.swUseHttps.isChecked();
60+
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
61+
saveMenu = menu.add(R.string.save);
62+
saveMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
63+
return super.onCreateOptionsMenu(menu);
7064
}
7165

7266
@Override
7367
public boolean onOptionsItemSelected(MenuItem item) {
74-
if (item.getItemId() == android.R.id.home) {
75-
this.finish();
68+
if (item.getItemId() == saveMenu.getItemId()) {
69+
GlobalSettings globalSettings = ((MainApplication)getApplication()).getGlobalSettings();
70+
globalSettings.privateCloudIp = mBinding.privateCloudLayout.etIpAddress.getText().toString();
71+
globalSettings.privateCloudLogReportEnable = mBinding.privateCloudLayout.swLogReport.isChecked();
72+
globalSettings.privateCloudLogServerDomain = mBinding.privateCloudLayout.etLogServerDomain.getText().toString();
73+
globalSettings.privateCloudLogServerPort = Integer.parseInt(mBinding.privateCloudLayout.etLogServerPort.getText().toString());
74+
globalSettings.privateCloudLogServerPath = mBinding.privateCloudLayout.etLogServerPath.getText().toString();
75+
globalSettings.privateCloudUseHttps = mBinding.privateCloudLayout.swUseHttps.isChecked();
76+
77+
globalSettings.setAreaCodeStr(getResources().getStringArray(R.array.areaCode)[mBinding.areaSpinner.getSelectedItemPosition()]);
78+
onBackPressed();
7679
return true;
7780
}
7881
return super.onOptionsItemSelected(item);
7982
}
8083

81-
@Override
82-
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
83-
if(adapterView.getId() == R.id.area_spinner){
84-
GlobalSettings globalSettings = ((MainApplication)getApplication()).getGlobalSettings();
85-
globalSettings.setAreaCodeStr(getResources().getStringArray(R.array.areaCode)[i]);
86-
}
87-
}
88-
89-
@Override
90-
public void onNothingSelected(AdapterView<?> adapterView) {
91-
92-
}
9384
}

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/RhythmPlayer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
8686
stop.setOnClickListener(this);
8787
beatPerMinute.setOnSeekBarChangeListener(this);
8888
beatPerMeasure.setOnSeekBarChangeListener(this);
89-
beatPerMeasure.setEnabled(false);
90-
beatPerMinute.setEnabled(false);
9189
}
9290

9391
@Override

0 commit comments

Comments
 (0)