Skip to content

Commit 3efde00

Browse files
committed
feat: refine pip for iOS and Android
1 parent 8efae11 commit 3efde00

34 files changed

+2430
-2199
lines changed

.pubignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
integration_test_app/
22
tool/
3-
test_shard/
3+
test_shard/
4+
docs/
5+
ci/
6+
scripts/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Please refer to the [Flutter documentation](https://docs.flutter.dev/platform-in
130130
* [Windows](https://api-ref.agora.io/en/video-sdk/cpp/4.x/API/rtc_api_overview_ng.html)
131131
* [Web](https://api-ref.agora.io/en/video-sdk/web/4.x/index.html)
132132

133+
## Integration document
134+
135+
* [Picture-in-Picture](docs/integration/Picture-in-Picture.md)
136+
133137
## Feedback
134138

135139
If you have any problems or suggestions regarding the sample projects, feel free to file an [issue](https://github.com/AgoraIO-Community/agora_rtc_engine/issues) OR pull request.

android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ dependencies {
6565
api 'io.agora.rtc:agora-special-full:4.3.2.11'
6666
api 'io.agora.rtc:full-screen-sharing:4.3.2.11'
6767
// native dependencies end
68+
69+
api 'io.agora.rtc:pip:0.0.1-rc.1'
6870
}
6971
}
7072

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package io.agora.agora_rtc_ng;
2+
3+
import io.flutter.embedding.android.FlutterActivity;
4+
5+
import android.app.PictureInPictureParams;
6+
import android.app.PictureInPictureUiState;
7+
import android.content.Context;
8+
import android.content.res.Configuration;
9+
10+
import java.lang.ref.WeakReference;
11+
12+
import io.agora.pip.AgoraPIPActivityProxy;
13+
import io.agora.pip.AgoraPIPActivityListener;
14+
15+
public class AgoraPIPFlutterActivity extends FlutterActivity implements AgoraPIPActivityProxy {
16+
private WeakReference<AgoraPIPActivityListener> mListener;
17+
18+
@Override
19+
public Context getApplicationContext() {
20+
return super.getApplicationContext();
21+
}
22+
23+
@Override
24+
public void setAgoraPIPActivityListener(AgoraPIPActivityListener listener) {
25+
mListener = new WeakReference<>(listener);
26+
}
27+
28+
@Override
29+
public boolean isInPictureInPictureMode() {
30+
return super.isInPictureInPictureMode();
31+
}
32+
33+
@Override
34+
public void setPictureInPictureParams(PictureInPictureParams params) {
35+
super.setPictureInPictureParams(params);
36+
}
37+
38+
@Override
39+
public boolean enterPictureInPictureMode(PictureInPictureParams params) {
40+
return super.enterPictureInPictureMode(params);
41+
}
42+
43+
@Override
44+
public void enterPictureInPictureMode() {
45+
super.enterPictureInPictureMode();
46+
}
47+
48+
@Override
49+
public boolean moveTaskToBack(boolean nonRoot) {
50+
return super.moveTaskToBack(nonRoot);
51+
}
52+
53+
@Override
54+
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode,
55+
Configuration newConfig) {
56+
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
57+
if (mListener == null) {
58+
return;
59+
}
60+
61+
AgoraPIPActivityListener listener = mListener.get();
62+
if (listener != null) {
63+
listener.onPictureInPictureModeChanged(isInPictureInPictureMode,
64+
newConfig);
65+
}
66+
}
67+
68+
@Override
69+
public boolean onPictureInPictureRequested() {
70+
if (mListener != null) {
71+
AgoraPIPActivityListener listener = mListener.get();
72+
if (listener != null) {
73+
return listener.onPictureInPictureRequested();
74+
}
75+
}
76+
77+
78+
return super.onPictureInPictureRequested();
79+
}
80+
81+
@Override
82+
public void onPictureInPictureUiStateChanged(PictureInPictureUiState state) {
83+
super.onPictureInPictureUiStateChanged(state);
84+
if (mListener == null) {
85+
return;
86+
}
87+
88+
AgoraPIPActivityListener listener = mListener.get();
89+
if (listener != null) {
90+
listener.onPictureInPictureUiStateChanged(state);
91+
}
92+
}
93+
94+
@Override
95+
public void onUserLeaveHint() {
96+
super.onUserLeaveHint();
97+
if (mListener == null) {
98+
return;
99+
}
100+
101+
AgoraPIPActivityListener listener = mListener.get();
102+
if (listener != null) {
103+
listener.onUserLeaveHint();
104+
}
105+
}
106+
}

android/src/main/java/io/agora/agora_rtc_ng/AgoraPipActivity.java

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)