Skip to content

Commit

Permalink
Full screen adaptation.
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycodeboy committed Dec 5, 2021
1 parent 6af465d commit b471976
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# react-native-splash-screen


[![Download](https://img.shields.io/badge/Download-v3.2.0-ff69b4.svg) ](https://www.npmjs.com/package/react-native-splash-screen)
[![Download](https://img.shields.io/badge/Download-v3.3.0-ff69b4.svg) ](https://www.npmjs.com/package/react-native-splash-screen)
[ ![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/crazycodeboy/react-native-splash-screen/pulls)
[ ![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)
[ ![语言 中文](https://img.shields.io/badge/语言-中文-feb252.svg)](https://github.com/crazycodeboy/react-native-splash-screen/blob/master/README.zh.md)
Expand Down Expand Up @@ -280,6 +280,7 @@ export default class WelcomePage extends Component {
| Method | Type | Optional | Description |
|--------|----------|----------|-------------------------------------|
| show() | function | false | Open splash screen (Native Method ) |
| show(final Activity activity, final boolean fullScreen) | function | false | Open splash screen (Native Method ) |
| hide() | function | false | Close splash screen |

## Testing
Expand Down
21 changes: 18 additions & 3 deletions android/src/main/java/org/devio/rn/splashscreen/SplashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.Dialog;
import android.os.Build;
import android.view.WindowManager;

import java.lang.ref.WeakReference;

Expand All @@ -21,7 +22,7 @@ public class SplashScreen {
/**
* 打开启动屏
*/
public static void show(final Activity activity, final int themeResId) {
public static void show(final Activity activity, final int themeResId, final boolean fullScreen) {
if (activity == null) return;
mActivity = new WeakReference<Activity>(activity);
activity.runOnUiThread(new Runnable() {
Expand All @@ -31,7 +32,9 @@ public void run() {
mSplashDialog = new Dialog(activity, themeResId);
mSplashDialog.setContentView(R.layout.launch_screen);
mSplashDialog.setCancelable(false);

if (fullScreen) {
setActivityAndroidP(mSplashDialog);
}
if (!mSplashDialog.isShowing()) {
mSplashDialog.show();
}
Expand All @@ -46,7 +49,7 @@ public void run() {
public static void show(final Activity activity, final boolean fullScreen) {
int resourceId = fullScreen ? R.style.SplashScreen_Fullscreen : R.style.SplashScreen_SplashTheme;

show(activity, resourceId);
show(activity, resourceId, fullScreen);
}

/**
Expand Down Expand Up @@ -89,4 +92,16 @@ public void run() {
}
});
}

private static void setActivityAndroidP(Dialog dialog) {
//设置全屏展示
if (Build.VERSION.SDK_INT >= 28) {
if (dialog != null && dialog.getWindow() != null) {
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);//全屏显示
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
dialog.getWindow().setAttributes(lp);
}
}
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-splash-screen",
"version": "3.2.0",
"version": "3.3.0",
"description": "A splash screen for react-native, hide when application loaded ,it works on iOS and Android.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -31,4 +31,4 @@
"react-native": ">=0.57.0"
},
"homepage": "https://github.com/crazycodeboy/react-native-splash-screen#readme"
}
}

1 comment on commit b471976

@simon-abbott
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change since the signature of show() was changed with no default value. This should have been a major version bump (v4.0.0), not a minor update.
If you're not going to follow semantic versioning please say so in the README.

Please sign in to comment.