Skip to content

Commit 47c58aa

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

26 files changed

+2010
-2187
lines changed

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: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
import android.os.Build;
10+
11+
import androidx.annotation.NonNull;
12+
import androidx.annotation.RequiresApi;
13+
14+
import java.lang.ref.WeakReference;
15+
16+
import io.agora.pip.AgoraPIPActivityProxy;
17+
import io.agora.pip.AgoraPIPActivityListener;
18+
19+
public class AgoraPIPFlutterActivity extends FlutterActivity implements AgoraPIPActivityProxy {
20+
private WeakReference<AgoraPIPActivityListener> mListener;
21+
22+
@Override
23+
public Context getApplicationContext() {
24+
return super.getApplicationContext();
25+
}
26+
27+
@Override
28+
public void setAgoraPIPActivityListener(AgoraPIPActivityListener listener) {
29+
mListener = new WeakReference<>(listener);
30+
}
31+
32+
@Override
33+
public boolean isInPictureInPictureMode() {
34+
return super.isInPictureInPictureMode();
35+
}
36+
37+
@Override
38+
public void setPictureInPictureParams(@NonNull PictureInPictureParams params) {
39+
super.setPictureInPictureParams(params);
40+
}
41+
42+
@Override
43+
public boolean enterPictureInPictureMode(@NonNull PictureInPictureParams params) {
44+
return super.enterPictureInPictureMode(params);
45+
}
46+
47+
@Override
48+
public void enterPictureInPictureMode() {
49+
super.enterPictureInPictureMode();
50+
}
51+
52+
@Override
53+
public boolean moveTaskToBack(boolean nonRoot) {
54+
return super.moveTaskToBack(nonRoot);
55+
}
56+
57+
// only available in API level 26 and above
58+
@RequiresApi(Build.VERSION_CODES.O)
59+
@Override
60+
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode,
61+
Configuration newConfig) {
62+
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
63+
if (mListener == null) {
64+
return;
65+
}
66+
67+
AgoraPIPActivityListener listener = mListener.get();
68+
if (listener != null) {
69+
listener.onPictureInPictureModeChanged(isInPictureInPictureMode,
70+
newConfig);
71+
}
72+
}
73+
74+
// only available in API level 30 and above
75+
@RequiresApi(Build.VERSION_CODES.R)
76+
@Override
77+
public boolean onPictureInPictureRequested() {
78+
if (mListener != null) {
79+
AgoraPIPActivityListener listener = mListener.get();
80+
if (listener != null) {
81+
return listener.onPictureInPictureRequested();
82+
}
83+
}
84+
85+
86+
return super.onPictureInPictureRequested();
87+
}
88+
89+
// only available in API level 31 and above
90+
@RequiresApi(Build.VERSION_CODES.S)
91+
@Override
92+
public void
93+
onPictureInPictureUiStateChanged(@NonNull PictureInPictureUiState state) {
94+
super.onPictureInPictureUiStateChanged(state);
95+
if (mListener == null) {
96+
return;
97+
}
98+
99+
AgoraPIPActivityListener listener = mListener.get();
100+
if (listener != null) {
101+
listener.onPictureInPictureUiStateChanged(state);
102+
}
103+
}
104+
105+
@Override
106+
public void onUserLeaveHint() {
107+
super.onUserLeaveHint();
108+
if (mListener == null) {
109+
return;
110+
}
111+
112+
AgoraPIPActivityListener listener = mListener.get();
113+
if (listener != null) {
114+
listener.onUserLeaveHint();
115+
}
116+
}
117+
}

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)