Skip to content

Commit b471976

Browse files
committed
Full screen adaptation.
1 parent 6af465d commit b471976

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# react-native-splash-screen
22

33

4-
[![Download](https://img.shields.io/badge/Download-v3.2.0-ff69b4.svg) ](https://www.npmjs.com/package/react-native-splash-screen)
4+
[![Download](https://img.shields.io/badge/Download-v3.3.0-ff69b4.svg) ](https://www.npmjs.com/package/react-native-splash-screen)
55
[ ![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/crazycodeboy/react-native-splash-screen/pulls)
66
[ ![react-native-splash-screen release](https://img.shields.io/github/release/crazycodeboy/react-native-splash-screen.svg?maxAge=2592000?style=flat-square)](https://github.com/crazycodeboy/GitHubPopular/releases)
77
[ ![语言 中文](https://img.shields.io/badge/语言-中文-feb252.svg)](https://github.com/crazycodeboy/react-native-splash-screen/blob/master/README.zh.md)
@@ -280,6 +280,7 @@ export default class WelcomePage extends Component {
280280
| Method | Type | Optional | Description |
281281
|--------|----------|----------|-------------------------------------|
282282
| show() | function | false | Open splash screen (Native Method ) |
283+
| show(final Activity activity, final boolean fullScreen) | function | false | Open splash screen (Native Method ) |
283284
| hide() | function | false | Close splash screen |
284285

285286
## Testing

android/src/main/java/org/devio/rn/splashscreen/SplashScreen.java

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Activity;
44
import android.app.Dialog;
55
import android.os.Build;
6+
import android.view.WindowManager;
67

78
import java.lang.ref.WeakReference;
89

@@ -21,7 +22,7 @@ public class SplashScreen {
2122
/**
2223
* 打开启动屏
2324
*/
24-
public static void show(final Activity activity, final int themeResId) {
25+
public static void show(final Activity activity, final int themeResId, final boolean fullScreen) {
2526
if (activity == null) return;
2627
mActivity = new WeakReference<Activity>(activity);
2728
activity.runOnUiThread(new Runnable() {
@@ -31,7 +32,9 @@ public void run() {
3132
mSplashDialog = new Dialog(activity, themeResId);
3233
mSplashDialog.setContentView(R.layout.launch_screen);
3334
mSplashDialog.setCancelable(false);
34-
35+
if (fullScreen) {
36+
setActivityAndroidP(mSplashDialog);
37+
}
3538
if (!mSplashDialog.isShowing()) {
3639
mSplashDialog.show();
3740
}
@@ -46,7 +49,7 @@ public void run() {
4649
public static void show(final Activity activity, final boolean fullScreen) {
4750
int resourceId = fullScreen ? R.style.SplashScreen_Fullscreen : R.style.SplashScreen_SplashTheme;
4851

49-
show(activity, resourceId);
52+
show(activity, resourceId, fullScreen);
5053
}
5154

5255
/**
@@ -89,4 +92,16 @@ public void run() {
8992
}
9093
});
9194
}
95+
96+
private static void setActivityAndroidP(Dialog dialog) {
97+
//设置全屏展示
98+
if (Build.VERSION.SDK_INT >= 28) {
99+
if (dialog != null && dialog.getWindow() != null) {
100+
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//全屏显示
101+
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
102+
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
103+
dialog.getWindow().setAttributes(lp);
104+
}
105+
}
106+
}
92107
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-splash-screen",
3-
"version": "3.2.0",
3+
"version": "3.3.0",
44
"description": "A splash screen for react-native, hide when application loaded ,it works on iOS and Android.",
55
"main": "index.js",
66
"scripts": {
@@ -31,4 +31,4 @@
3131
"react-native": ">=0.57.0"
3232
},
3333
"homepage": "https://github.com/crazycodeboy/react-native-splash-screen#readme"
34-
}
34+
}

0 commit comments

Comments
 (0)