|
@@ -1,5 +1,5 @@
|
1
|
1
|
/*
|
2
|
|
- * Copyright @ 2017-present Atlassian Pty Ltd
|
|
2
|
+ * Copyright @ 2017-present 8x8, Inc.
|
3
|
3
|
*
|
4
|
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -18,6 +18,7 @@ package org.jitsi.meet.sdk;
|
18
|
18
|
|
19
|
19
|
import android.annotation.TargetApi;
|
20
|
20
|
import android.app.Activity;
|
|
21
|
+import android.app.ActivityManager;
|
21
|
22
|
import android.app.PictureInPictureParams;
|
22
|
23
|
import android.os.Build;
|
23
|
24
|
import android.util.Rational;
|
|
@@ -30,20 +31,41 @@ import com.facebook.react.module.annotations.ReactModule;
|
30
|
31
|
|
31
|
32
|
import org.jitsi.meet.sdk.log.JitsiMeetLogger;
|
32
|
33
|
|
|
34
|
+import java.util.HashMap;
|
|
35
|
+import java.util.Map;
|
|
36
|
+
|
|
37
|
+import static android.content.Context.ACTIVITY_SERVICE;
|
|
38
|
+
|
33
|
39
|
@ReactModule(name = PictureInPictureModule.NAME)
|
34
|
|
-class PictureInPictureModule
|
35
|
|
- extends ReactContextBaseJavaModule {
|
|
40
|
+class PictureInPictureModule extends ReactContextBaseJavaModule {
|
36
|
41
|
|
37
|
42
|
public static final String NAME = "PictureInPicture";
|
38
|
|
-
|
39
|
43
|
private static final String TAG = NAME;
|
40
|
44
|
|
41
|
|
- static boolean isPictureInPictureSupported() {
|
42
|
|
- return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
|
43
|
|
- }
|
|
45
|
+ private static boolean isSupported;
|
44
|
46
|
|
45
|
47
|
public PictureInPictureModule(ReactApplicationContext reactContext) {
|
46
|
48
|
super(reactContext);
|
|
49
|
+
|
|
50
|
+ ActivityManager am = (ActivityManager) reactContext.getSystemService(ACTIVITY_SERVICE);
|
|
51
|
+
|
|
52
|
+ // Android Go devices don't support PiP. There doesn't seem to be a better way to detect it than
|
|
53
|
+ // to use ActivityManager.isLowRamDevice().
|
|
54
|
+ // https://stackoverflow.com/questions/58340558/how-to-detect-android-go
|
|
55
|
+ isSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !am.isLowRamDevice();
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ /**
|
|
59
|
+ * Gets a {@code Map} of constants this module exports to JS. Supports JSON
|
|
60
|
+ * types.
|
|
61
|
+ *
|
|
62
|
+ * @return a {@link Map} of constants this module exports to JS
|
|
63
|
+ */
|
|
64
|
+ @Override
|
|
65
|
+ public Map<String, Object> getConstants() {
|
|
66
|
+ Map<String, Object> constants = new HashMap<>();
|
|
67
|
+ constants.put("SUPPORTED", isSupported);
|
|
68
|
+ return constants;
|
47
|
69
|
}
|
48
|
70
|
|
49
|
71
|
/**
|
|
@@ -61,7 +83,7 @@ class PictureInPictureModule
|
61
|
83
|
*/
|
62
|
84
|
@TargetApi(Build.VERSION_CODES.O)
|
63
|
85
|
public void enterPictureInPicture() {
|
64
|
|
- if (!isPictureInPictureSupported()) {
|
|
86
|
+ if (!isSupported) {
|
65
|
87
|
throw new IllegalStateException("Picture-in-Picture not supported");
|
66
|
88
|
}
|
67
|
89
|
|
|
@@ -104,6 +126,10 @@ class PictureInPictureModule
|
104
|
126
|
}
|
105
|
127
|
}
|
106
|
128
|
|
|
129
|
+ public boolean isPictureInPictureSupported() {
|
|
130
|
+ return isSupported;
|
|
131
|
+ }
|
|
132
|
+
|
107
|
133
|
@Override
|
108
|
134
|
public String getName() {
|
109
|
135
|
return NAME;
|