Skip to content

Commit 7fded58

Browse files
committed
[Android]Build a framework for third-party beauty module.
1 parent 65ceaef commit 7fded58

51 files changed

Lines changed: 6468 additions & 3 deletions

Some content is hidden

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

Android/APIExample/app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,9 @@ dependencies {
8686

8787
implementation "com.squareup.okhttp3:okhttp:4.10.0"
8888
implementation "com.squareup.okhttp3:logging-interceptor:4.10.0"
89+
90+
implementation project(path: ':beauty:base')
91+
if(beauty_sensetime.toBoolean()){
92+
runtimeOnly project(path: ':beauty:sense-time')
93+
}
8994
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package io.agora.api.example.examples.advanced;
2+
3+
import static io.agora.api.example.common.model.Examples.ADVANCED;
4+
5+
import android.os.Bundle;
6+
import android.text.TextUtils;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
import android.widget.EditText;
11+
import android.widget.Spinner;
12+
import android.widget.Toast;
13+
14+
import androidx.annotation.NonNull;
15+
import androidx.annotation.Nullable;
16+
import androidx.navigation.Navigation;
17+
18+
import io.agora.api.example.R;
19+
import io.agora.api.example.annotation.Example;
20+
import io.agora.api.example.common.BaseFragment;
21+
22+
@Example(
23+
index = 24,
24+
group = ADVANCED,
25+
name = R.string.item_third_party_beauty,
26+
actionId = R.id.action_mainFragment_to_third_party_beauty,
27+
tipsId = R.string.third_party_beauty
28+
)
29+
public class ThirdPartyBeauty extends BaseFragment {
30+
31+
private EditText etChannel;
32+
private Spinner snBeautyType;
33+
private int[] beautyActionIds;
34+
35+
@Nullable
36+
@Override
37+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
38+
return inflater.inflate(R.layout.fragment_third_party_beauty, container, false);
39+
}
40+
41+
@Override
42+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
43+
super.onViewCreated(view, savedInstanceState);
44+
etChannel = view.findViewById(R.id.et_channel);
45+
snBeautyType = view.findViewById(R.id.sn_beauty_type);
46+
beautyActionIds = new int[]{
47+
R.id.action_third_party_beauty_to_scene_time
48+
};
49+
50+
view.findViewById(R.id.btn_join).setOnClickListener(v -> {
51+
int index = snBeautyType.getSelectedItemPosition();
52+
if (index >= beautyActionIds.length) {
53+
return;
54+
}
55+
String channelName = etChannel.getText().toString();
56+
if (TextUtils.isEmpty(channelName)) {
57+
Toast.makeText(getContext(), "The channel name is empty!", Toast.LENGTH_SHORT).show();
58+
return;
59+
}
60+
Bundle args = new Bundle();
61+
args.putString(getString(R.string.key_channel_name), channelName);
62+
Navigation.findNavController(view)
63+
.navigate(beautyActionIds[index], args);
64+
});
65+
}
66+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package io.agora.api.example.examples.advanced.beauty;
2+
3+
import android.os.Bundle;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
8+
import androidx.annotation.NonNull;
9+
import androidx.annotation.Nullable;
10+
11+
import io.agora.api.example.R;
12+
import io.agora.api.example.common.BaseFragment;
13+
import io.agora.beauty.base.IBeautySenseTime;
14+
15+
public class SceneTimeBeauty extends BaseFragment {
16+
17+
private IBeautySenseTime iBeautySenseTime;
18+
19+
@Nullable
20+
@Override
21+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
22+
return inflater.inflate(R.layout.fragment_scenetime_beauty, container, false);
23+
}
24+
25+
@Override
26+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
27+
super.onViewCreated(view, savedInstanceState);
28+
iBeautySenseTime = IBeautySenseTime.create(getContext());
29+
if(iBeautySenseTime == null){
30+
// TODO show the readme of compiling scene-time library.
31+
initReadMeView();
32+
return;
33+
}
34+
35+
initVideoView();
36+
initRtcEngine();
37+
}
38+
39+
private void initReadMeView() {
40+
41+
}
42+
43+
private void initVideoView() {
44+
45+
}
46+
47+
private void initRtcEngine() {
48+
49+
}
50+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent">
5+
6+
<TextView
7+
android:layout_width="wrap_content"
8+
android:layout_height="wrap_content"
9+
android:layout_gravity="center"
10+
android:padding="12dp"
11+
android:lineSpacingExtra="2dp"
12+
android:textSize="18sp"
13+
android:text="商汤库没有集成!请按下面方法集成后再编译:\n1. 在gradle.properties里设置beauty_sensetime=true\n2. 下载商汤SDK,将解压后的aar库放在beauty/sense-time里对应的目录下,具体文件可以参考文件夹下的PLACEHODLE\n3. 配置licsence后运行"
14+
android:textColor="@android:color/black" />
15+
16+
</FrameLayout>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:gravity="center_vertical"
6+
android:orientation="vertical"
7+
android:paddingHorizontal="30dp">
8+
9+
10+
<EditText
11+
android:id="@+id/et_channel"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:hint="@string/channel_id" />
15+
16+
<Spinner
17+
android:id="@+id/sn_beauty_type"
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:layout_marginTop="12dp"
21+
android:layout_gravity="end"
22+
android:entries="@array/beauty" />
23+
24+
<Button
25+
android:id="@+id/btn_join"
26+
android:layout_marginTop="12dp"
27+
android:layout_width="match_parent"
28+
android:layout_height="wrap_content"
29+
android:text="@string/join" />
30+
31+
</LinearLayout>

Android/APIExample/app/src/main/res/navigation/nav_graph.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
<action
120120
android:id="@+id/action_mainFragment_to_picture_in_picture"
121121
app:destination="@id/pictureInPicture" />
122+
<action
123+
android:id="@+id/action_mainFragment_to_third_party_beauty"
124+
app:destination="@id/thirdPartyBeauty" />
122125
</fragment>
123126

124127
<fragment
@@ -145,6 +148,25 @@
145148
app:destination="@id/CDNHost" />
146149

147150
</fragment>
151+
152+
<fragment
153+
android:id="@+id/thirdPartyBeauty"
154+
android:name="io.agora.api.example.examples.advanced.ThirdPartyBeauty"
155+
android:label="@string/item_third_party_beauty"
156+
tools:layout="@layout/fragment_third_party_beauty">
157+
158+
<action
159+
android:id="@+id/action_third_party_beauty_to_scene_time"
160+
app:destination="@id/SceneTimeBeauty" />
161+
162+
</fragment>
163+
164+
<fragment
165+
android:id="@+id/SceneTimeBeauty"
166+
android:name="io.agora.api.example.examples.advanced.beauty.SceneTimeBeauty"
167+
android:label="@string/item_beauty_scenetime"
168+
tools:layout="@layout/fragment_scenetime_beauty" />
169+
148170
<fragment
149171
android:id="@+id/RTCToRTMP"
150172
android:name="io.agora.api.example.examples.advanced.RTMPStreaming"

Android/APIExample/app/src/main/res/values-zh/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<string name="item_spatial_sound">空间音效</string>
117117
<string name="item_content_inspect">视频鉴黄</string>
118118
<string name="item_picture_in_picture">画中画</string>
119+
<string name="item_third_party_beauty">第三方美颜</string>
119120

120121
<string name="joinchannelaudio">此示例演示了如何使用SDK加入频道进行纯语音通话的功能。</string>
121122
<string name="joinchannelvideo">此示例演示了如何使用SDK加入频道进行音视频通话的功能。</string>
@@ -174,6 +175,7 @@
174175
<string name="spatial_sound_tip_playing">你会听到一段音乐, 10秒后这段音乐会通过空间音效的方式播放</string>
175176
<string name="content_inspect">此示例演示了如何使用SDK进行视频鉴黄的功能。</string>
176177
<string name="picture_in_picture">此示例演示了如何在画中画中使用sdk进行远端视频显示的功能。</string>
178+
<string name="third_party_beauty">此示例演示了如何集成第三方美颜sdk</string>
177179

178180
<string name="audio_source_play_out">本地</string>
179181
<string name="audio_source_pre_process">SDK处理前</string>
@@ -249,4 +251,5 @@
249251
<string name="float_window_confirm_dialog_confirm">现在去开启</string>
250252
<string name="float_window_confirm_dialog_cancel">暂不开启</string>
251253
<string name="float_window_show">显示悬浮窗</string>
254+
<string name="item_beauty_scenetime">商汤美颜</string>
252255
</resources>

Android/APIExample/app/src/main/res/values/arrays.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,9 @@
204204
<item>FRAME_RATE_FPS_24</item>
205205
<item>FRAME_RATE_FPS_30</item>
206206
</string-array>
207+
208+
<string-array name="beauty">
209+
<item>@string/item_beauty_scenetime</item>
210+
</string-array>
211+
207212
</resources>

Android/APIExample/app/src/main/res/values/strings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<string name="item_spatial_sound">Spatial Audio</string>
121121
<string name="item_content_inspect">Content Inspect</string>
122122
<string name="item_picture_in_picture">Picture In Picture</string>
123+
<string name="item_third_party_beauty">Third-party beauty</string>
123124

124125
<string name="joinchannelaudio">This example demonstrates how to use the SDK to join channels for voice only calls.</string>
125126
<string name="joinchannelvideo">This example demonstrates how to use the SDK to join channels for audio and video calls.</string>
@@ -180,6 +181,7 @@
180181
<string name="spatial_sound_tip_playing">You will hear a piece of music, and after 10 seconds this piece of music will be played through spatial audio effects</string>
181182
<string name="content_inspect">This example demonstrates how to use the SDK to inspect content.</string>
182183
<string name="picture_in_picture">This example demonstrates how to show remove video in Picture In Picture mode.</string>
184+
<string name="third_party_beauty">This example demonstrates how to integrate third-party beauty sdk.</string>
183185

184186
<string name="audio_source_play_out">PlayOut</string>
185187
<string name="audio_source_pre_process">PreProcess</string>
@@ -189,8 +191,8 @@
189191
<string name="agora_channel_hint">Enter Channel Name</string>
190192
<string name="stream_mode">Stream Mode</string>
191193
<string name="cdn_url_hint">Set CDN URL</string>
192-
<string name="key_channel_name">channelName</string>
193-
<string name="key_is_agora_channel">isAgoraChannel</string>
194+
<string name="key_channel_name" translatable="false">channelName</string>
195+
<string name="key_is_agora_channel" translatable="false">isAgoraChannel</string>
194196
<string name="rtc_streaming">RTC Streaming</string>
195197
<string name="start_live_streaming">Start Live Streaming</string>
196198
<string name="recording_vol">Recording Vol</string>
@@ -257,4 +259,5 @@
257259
<string name="float_window_confirm_dialog_confirm">Open Now</string>
258260
<string name="float_window_confirm_dialog_cancel">Not Now</string>
259261
<string name="float_window_show">Show Float Window</string>
262+
<string name="item_beauty_scenetime">SceneTimeBeauty</string>
260263
</resources>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

0 commit comments

Comments
 (0)