@byteplus/react-native-live-pull 1.1.1-rc.0 → 1.1.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/volcengine/velive/rn/pull/pictureInpicture/FloatingWindowService.java +45 -18
- package/android/src/main/java/com/volcengine/velive/rn/pull/pictureInpicture/PictureInPictureManager.java +0 -23
- package/android/src/main/res/drawable/button_close.xml +6 -11
- package/android/src/main/res/drawable/new_window.xml +16 -0
- package/android/src/main/res/layout/floating_window_layout.xml +13 -3
- package/lib/commonjs/index.js +1167 -1948
- package/lib/module/index.js +1167 -1948
- package/lib/typescript/codegen/pack/errorcode.d.ts +24 -24
- package/lib/typescript/codegen/pack/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023 Beijing Volcano Engine Technology Ltd. All rights
|
|
3
|
-
* reserved. Licensed under the MIT License (the "License"); you may not use
|
|
4
|
-
* this file except in compliance with the License. You may obtain a copy of the
|
|
5
|
-
* License at http://opensource.org/licenses/MIT Unless required by applicable
|
|
6
|
-
* law or agreed to in writing, software distributed under the License is
|
|
7
|
-
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
8
|
-
* KIND, either express or implied. See the License for the specific language
|
|
9
|
-
* governing permissions and limitations under the License.
|
|
10
|
-
*/
|
|
11
1
|
package com.volcengine.velive.rn.pull.pictureInpicture;
|
|
12
2
|
|
|
13
3
|
import android.app.Service;
|
|
@@ -16,6 +6,7 @@ import android.graphics.PixelFormat;
|
|
|
16
6
|
import android.os.Build;
|
|
17
7
|
import android.os.IBinder;
|
|
18
8
|
import android.provider.Settings;
|
|
9
|
+
import android.util.DisplayMetrics; // Import DisplayMetrics
|
|
19
10
|
import android.util.Log;
|
|
20
11
|
import android.view.Gravity;
|
|
21
12
|
import android.view.LayoutInflater;
|
|
@@ -29,7 +20,7 @@ import com.volcengine.velive.rn.pull.R;
|
|
|
29
20
|
|
|
30
21
|
public class FloatingWindowService extends Service {
|
|
31
22
|
private static final String TAG = FloatingWindowService.class.getSimpleName();
|
|
32
|
-
private static final int LONGER_SIDE_MAX_LEN =
|
|
23
|
+
private static final int LONGER_SIDE_MAX_LEN = 1000;
|
|
33
24
|
|
|
34
25
|
private WindowManager mWindowManager;
|
|
35
26
|
private WindowManager.LayoutParams mLayoutParams;
|
|
@@ -86,16 +77,29 @@ public class FloatingWindowService extends Service {
|
|
|
86
77
|
mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
|
|
87
78
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
|
88
79
|
|
|
80
|
+
// Get screen dimensions
|
|
81
|
+
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
82
|
+
mWindowManager.getDefaultDisplay().getMetrics(displayMetrics);
|
|
83
|
+
int screenWidth = displayMetrics.widthPixels;
|
|
84
|
+
int screenHeight = displayMetrics.heightPixels;
|
|
85
|
+
|
|
86
|
+
// Calculate the minimum screen dimension
|
|
87
|
+
int minScreenDim = Math.min(screenWidth, screenHeight);
|
|
88
|
+
|
|
89
|
+
// Determine the maximum length based on the smaller of 1000 and
|
|
90
|
+
// minScreenDim
|
|
91
|
+
int maxLen = Math.min(LONGER_SIDE_MAX_LEN, minScreenDim);
|
|
92
|
+
|
|
89
93
|
// Limit the floating window size to prevent it from being too large or too
|
|
90
|
-
// small, control the longer side to
|
|
94
|
+
// small, control the longer side to maxLen, scale the shorter
|
|
91
95
|
// side proportionally
|
|
92
96
|
int width, height;
|
|
93
97
|
if (aspectRatio >= 1) {
|
|
94
|
-
height = (int)(
|
|
95
|
-
width =
|
|
98
|
+
height = (int)(maxLen / aspectRatio);
|
|
99
|
+
width = maxLen;
|
|
96
100
|
} else {
|
|
97
|
-
width = (int)(
|
|
98
|
-
height =
|
|
101
|
+
width = (int)(maxLen * aspectRatio);
|
|
102
|
+
height = maxLen;
|
|
99
103
|
}
|
|
100
104
|
mLayoutParams.width = width;
|
|
101
105
|
mLayoutParams.height = height;
|
|
@@ -113,9 +117,32 @@ public class FloatingWindowService extends Service {
|
|
|
113
117
|
mWindowManager.addView(mSmallWindowView, mLayoutParams);
|
|
114
118
|
mSurfaceView = mSmallWindowView.findViewById(R.id.surface_view);
|
|
115
119
|
mSmallWindowView.findViewById(R.id.surface_close_btn)
|
|
120
|
+
.setOnClickListener(v -> { stopSelf(); });
|
|
121
|
+
|
|
122
|
+
mSmallWindowView.findViewById(R.id.new_window_btn)
|
|
116
123
|
.setOnClickListener(v -> {
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
Log.d(TAG, "PIP window clicked");
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
// Get the pacain activity
|
|
128
|
+
String packageName = this.getPackageName();
|
|
129
|
+
Intent launchIntent =
|
|
130
|
+
this.getPackageManager().getLaunchIntentForPackage(
|
|
131
|
+
packageName);
|
|
132
|
+
|
|
133
|
+
if (launchIntent != null) {
|
|
134
|
+
Log.d(TAG, "Launching app with intent: " + launchIntent);
|
|
135
|
+
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
136
|
+
this.startActivity(launchIntent);
|
|
137
|
+
} else {
|
|
138
|
+
Log.e(TAG, "Could not create launch intent for package: " +
|
|
139
|
+
packageName);
|
|
140
|
+
}
|
|
141
|
+
} catch (Exception e) {
|
|
142
|
+
Log.e(TAG, "Error launching app: " + e.getMessage(), e);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
stopSelf();
|
|
119
146
|
});
|
|
120
147
|
}
|
|
121
148
|
}
|
|
@@ -187,29 +187,6 @@ public class PictureInPictureManager {
|
|
|
187
187
|
if (mListener != null) {
|
|
188
188
|
mListener.onClickPictureInPicture();
|
|
189
189
|
}
|
|
190
|
-
Log.d(TAG, "PIP window clicked");
|
|
191
|
-
|
|
192
|
-
try {
|
|
193
|
-
// Get the package manager and launch the app's main activity
|
|
194
|
-
String packageName = context.getPackageName();
|
|
195
|
-
Intent launchIntent =
|
|
196
|
-
context.getPackageManager().getLaunchIntentForPackage(
|
|
197
|
-
packageName);
|
|
198
|
-
|
|
199
|
-
if (launchIntent != null) {
|
|
200
|
-
Log.d(TAG, "Launching app with intent: " + launchIntent);
|
|
201
|
-
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
202
|
-
context.startActivity(launchIntent);
|
|
203
|
-
} else {
|
|
204
|
-
Log.e(TAG, "Could not create launch intent for package: " +
|
|
205
|
-
packageName);
|
|
206
|
-
}
|
|
207
|
-
} catch (Exception e) {
|
|
208
|
-
Log.e(TAG, "Error launching app: " + e.getMessage(), e);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Close the floating window
|
|
212
|
-
mFloatingWindowHelper.closeFloatingWindow(context);
|
|
213
190
|
}
|
|
214
191
|
|
|
215
192
|
@Override
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
android:viewportHeight="612">
|
|
2
|
+
android:width="24dp"
|
|
3
|
+
android:height="24dp"
|
|
4
|
+
android:viewportWidth="24"
|
|
5
|
+
android:viewportHeight="24">
|
|
7
6
|
<path
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
306c0,168.995 137.004,306 306,306C474.995,612 612,474.995 612,
|
|
11
|
-
306zM168.3,424.032L286.333,306L168.3,187.967l19.667,-19.667L306,
|
|
12
|
-
286.333L424.032,168.3l19.668,19.667L325.667,306L443.7,424.032L424.032,
|
|
13
|
-
443.7L306,325.667L187.967,443.7L168.3,424.032z" />
|
|
7
|
+
android:fillColor="#FFFFFF"
|
|
8
|
+
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
|
|
14
9
|
</vector>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
android:width="48dp"
|
|
3
|
+
android:height="48dp"
|
|
4
|
+
android:viewportWidth="48.0"
|
|
5
|
+
android:viewportHeight="48.0">
|
|
6
|
+
<path
|
|
7
|
+
android:fillColor="#FFFFFF"
|
|
8
|
+
android:pathData="M6,4H22V8H8V40H40V26H44V42C44,43.1046 43.1046,44 42,44H6C4.89543,44 4,43.1046 4,42V6C4,4.89543 4.89543,4 6,4Z"/>
|
|
9
|
+
<path
|
|
10
|
+
android:fillColor="#FFFFFF"
|
|
11
|
+
android:pathData="M44,20V6C44,4.89543 43.1046,4 42,4H28V8H40V20H44Z"/>
|
|
12
|
+
<path
|
|
13
|
+
android:fillColor="#FFFFFF"
|
|
14
|
+
android:fillType="evenOdd"
|
|
15
|
+
android:pathData="M42.0711,4C43.1756,4 44.0711,4.89543 44.0711,6V20H40.0711V10.828L28.1213,22.7782C27.7308,23.1687 27.0976,23.1687 26.7071,22.7782L25.2929,21.364C24.9024,20.9734 24.9024,20.3403 25.2929,19.9497L37.2421,7.999L28.0711,8V4L42.0711,4Z"/>
|
|
16
|
+
</vector>
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
<RelativeLayout
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
android:layout_width="match_parent"
|
|
5
|
-
android:layout_height="match_parent"
|
|
5
|
+
android:layout_height="match_parent"
|
|
6
|
+
>
|
|
6
7
|
|
|
7
8
|
<SurfaceView
|
|
8
9
|
android:id="@+id/surface_view"
|
|
9
10
|
android:layout_width="match_parent"
|
|
10
|
-
android:layout_height="match_parent"
|
|
11
|
-
|
|
11
|
+
android:layout_height="match_parent"
|
|
12
|
+
></SurfaceView>
|
|
12
13
|
<Button
|
|
13
14
|
android:id="@+id/surface_close_btn"
|
|
14
15
|
android:background="@drawable/button_close"
|
|
@@ -16,4 +17,13 @@
|
|
|
16
17
|
android:layout_height="20dp"
|
|
17
18
|
android:layout_marginTop="4dp"
|
|
18
19
|
android:layout_marginStart="4dp" />
|
|
20
|
+
<Button
|
|
21
|
+
android:id="@+id/new_window_btn"
|
|
22
|
+
android:background="@drawable/new_window"
|
|
23
|
+
android:layout_width="16dp"
|
|
24
|
+
android:layout_height="16dp"
|
|
25
|
+
android:layout_marginTop="4dp"
|
|
26
|
+
android:layout_marginEnd="4dp"
|
|
27
|
+
android:layout_alignParentTop="true"
|
|
28
|
+
android:layout_alignParentEnd="true" />
|
|
19
29
|
</RelativeLayout>
|