react-native-bootsplash 7.2.0 → 7.3.0
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/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeRNBootSplashSpec.java +78 -0
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
- package/android/app/build/generated/source/codegen/jni/RNBootSplashSpec-generated.cpp +44 -0
- package/android/app/build/generated/source/codegen/jni/RNBootSplashSpec.h +31 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNBootSplashSpec/RNBootSplashSpecJSI-generated.cpp +39 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNBootSplashSpec/RNBootSplashSpecJSI.h +85 -0
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.kt +0 -1
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.kt +84 -104
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashPackage.kt +6 -15
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashView.kt +50 -0
- package/android/src/main/res/values/styles.xml +0 -10
- package/dist/commonjs/extras/addon/index.js +31 -31
- package/dist/commonjs/extras/addon/index.js.map +1 -1
- package/dist/commonjs/extras/utils.js +10 -9
- package/dist/commonjs/extras/utils.js.map +1 -1
- package/dist/module/extras/addon/index.js +31 -31
- package/dist/module/extras/addon/index.js.map +1 -1
- package/dist/module/extras/utils.js +10 -9
- package/dist/module/extras/utils.js.map +1 -1
- package/dist/typescript/commonjs/extras/addon/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/extras/utils.d.ts +2 -0
- package/dist/typescript/commonjs/extras/utils.d.ts.map +1 -1
- package/dist/typescript/module/extras/addon/index.d.ts.map +1 -1
- package/dist/typescript/module/extras/utils.d.ts +2 -0
- package/dist/typescript/module/extras/utils.d.ts.map +1 -1
- package/ios/RNBootSplash.xcodeproj/project.xcworkspace/xcuserdata/zoontek.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNBootSplash.xcodeproj/xcuserdata/zoontek.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/package.json +8 -8
- package/src/extras/utils.ts +12 -12
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.kt +0 -79
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashQueue.kt +0 -26
- package/android/src/main/res/anim/bootsplash_fade_out.xml +0 -6
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.facebook.fbreact.specs;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.common.build.ReactBuildConfig;
|
|
21
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
22
|
+
import java.util.Arrays;
|
|
23
|
+
import java.util.HashSet;
|
|
24
|
+
import java.util.Map;
|
|
25
|
+
import java.util.Set;
|
|
26
|
+
import javax.annotation.Nonnull;
|
|
27
|
+
import javax.annotation.Nullable;
|
|
28
|
+
|
|
29
|
+
public abstract class NativeRNBootSplashSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
30
|
+
public static final String NAME = "RNBootSplash";
|
|
31
|
+
|
|
32
|
+
public NativeRNBootSplashSpec(ReactApplicationContext reactContext) {
|
|
33
|
+
super(reactContext);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Override
|
|
37
|
+
public @Nonnull String getName() {
|
|
38
|
+
return NAME;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected abstract Map<String, Object> getTypedExportedConstants();
|
|
42
|
+
|
|
43
|
+
@Override
|
|
44
|
+
@DoNotStrip
|
|
45
|
+
public final @Nullable Map<String, Object> getConstants() {
|
|
46
|
+
Map<String, Object> constants = getTypedExportedConstants();
|
|
47
|
+
if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
|
|
48
|
+
Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
|
|
49
|
+
"darkModeEnabled"
|
|
50
|
+
));
|
|
51
|
+
Set<String> optionalFlowConstants = new HashSet<>(Arrays.asList(
|
|
52
|
+
"logoSizeRatio",
|
|
53
|
+
"navigationBarHeight",
|
|
54
|
+
"statusBarHeight"
|
|
55
|
+
));
|
|
56
|
+
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
|
|
57
|
+
undeclaredConstants.removeAll(obligatoryFlowConstants);
|
|
58
|
+
undeclaredConstants.removeAll(optionalFlowConstants);
|
|
59
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
60
|
+
throw new IllegalStateException(String.format("Native Module Flow doesn't declare constants: %s", undeclaredConstants));
|
|
61
|
+
}
|
|
62
|
+
undeclaredConstants = obligatoryFlowConstants;
|
|
63
|
+
undeclaredConstants.removeAll(constants.keySet());
|
|
64
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
65
|
+
throw new IllegalStateException(String.format("Native Module doesn't fill in constants: %s", undeclaredConstants));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return constants;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@ReactMethod
|
|
72
|
+
@DoNotStrip
|
|
73
|
+
public abstract void hide(boolean fade, Promise promise);
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
@DoNotStrip
|
|
77
|
+
public abstract void isVisible(Promise promise);
|
|
78
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNBootSplashSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_RNBootSplashSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_RNBootSplashSpec PUBLIC . react/renderer/components/RNBootSplashSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_RNBootSplashSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_options(
|
|
29
|
+
react_codegen_RNBootSplashSpec
|
|
30
|
+
PRIVATE
|
|
31
|
+
-DLOG_TAG=\"ReactNative\"
|
|
32
|
+
-fexceptions
|
|
33
|
+
-frtti
|
|
34
|
+
-std=c++20
|
|
35
|
+
-Wall
|
|
36
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "RNBootSplashSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeRNBootSplashSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, ObjectKind, "getConstants", "()Ljava/util/Map;", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeRNBootSplashSpecJSI_hide(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "hide", "(ZLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static facebook::jsi::Value __hostFunction_NativeRNBootSplashSpecJSI_isVisible(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
26
|
+
static jmethodID cachedMethodId = nullptr;
|
|
27
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "isVisible", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
NativeRNBootSplashSpecJSI::NativeRNBootSplashSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
31
|
+
: JavaTurboModule(params) {
|
|
32
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeRNBootSplashSpecJSI_getConstants};
|
|
33
|
+
methodMap_["hide"] = MethodMetadata {1, __hostFunction_NativeRNBootSplashSpecJSI_hide};
|
|
34
|
+
methodMap_["isVisible"] = MethodMetadata {0, __hostFunction_NativeRNBootSplashSpecJSI_isVisible};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
std::shared_ptr<TurboModule> RNBootSplashSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
38
|
+
if (moduleName == "RNBootSplash") {
|
|
39
|
+
return std::make_shared<NativeRNBootSplashSpecJSI>(params);
|
|
40
|
+
}
|
|
41
|
+
return nullptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeRNBootSplash'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeRNBootSplashSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeRNBootSplashSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> RNBootSplashSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNBootSplashSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeRNBootSplashCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeRNBootSplashCxxSpecJSI *>(&turboModule)->getConstants(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
static jsi::Value __hostFunction_NativeRNBootSplashCxxSpecJSI_hide(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<NativeRNBootSplashCxxSpecJSI *>(&turboModule)->hide(
|
|
21
|
+
rt,
|
|
22
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asBool()
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
static jsi::Value __hostFunction_NativeRNBootSplashCxxSpecJSI_isVisible(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
26
|
+
return static_cast<NativeRNBootSplashCxxSpecJSI *>(&turboModule)->isVisible(
|
|
27
|
+
rt
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
NativeRNBootSplashCxxSpecJSI::NativeRNBootSplashCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
32
|
+
: TurboModule("RNBootSplash", jsInvoker) {
|
|
33
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeRNBootSplashCxxSpecJSI_getConstants};
|
|
34
|
+
methodMap_["hide"] = MethodMetadata {1, __hostFunction_NativeRNBootSplashCxxSpecJSI_hide};
|
|
35
|
+
methodMap_["isVisible"] = MethodMetadata {0, __hostFunction_NativeRNBootSplashCxxSpecJSI_isVisible};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeRNBootSplashCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeRNBootSplashCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;
|
|
24
|
+
virtual jsi::Value hide(jsi::Runtime &rt, bool fade) = 0;
|
|
25
|
+
virtual jsi::Value isVisible(jsi::Runtime &rt) = 0;
|
|
26
|
+
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
template <typename T>
|
|
30
|
+
class JSI_EXPORT NativeRNBootSplashCxxSpec : public TurboModule {
|
|
31
|
+
public:
|
|
32
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
33
|
+
return delegate_.get(rt, propName);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static constexpr std::string_view kModuleName = "RNBootSplash";
|
|
37
|
+
|
|
38
|
+
protected:
|
|
39
|
+
NativeRNBootSplashCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
40
|
+
: TurboModule(std::string{NativeRNBootSplashCxxSpec::kModuleName}, jsInvoker),
|
|
41
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
class Delegate : public NativeRNBootSplashCxxSpecJSI {
|
|
46
|
+
public:
|
|
47
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
48
|
+
NativeRNBootSplashCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
jsi::Object getConstants(jsi::Runtime &rt) override {
|
|
53
|
+
static_assert(
|
|
54
|
+
bridging::getParameterCount(&T::getConstants) == 1,
|
|
55
|
+
"Expected getConstants(...) to have 1 parameters");
|
|
56
|
+
|
|
57
|
+
return bridging::callFromJs<jsi::Object>(
|
|
58
|
+
rt, &T::getConstants, jsInvoker_, instance_);
|
|
59
|
+
}
|
|
60
|
+
jsi::Value hide(jsi::Runtime &rt, bool fade) override {
|
|
61
|
+
static_assert(
|
|
62
|
+
bridging::getParameterCount(&T::hide) == 2,
|
|
63
|
+
"Expected hide(...) to have 2 parameters");
|
|
64
|
+
|
|
65
|
+
return bridging::callFromJs<jsi::Value>(
|
|
66
|
+
rt, &T::hide, jsInvoker_, instance_, std::move(fade));
|
|
67
|
+
}
|
|
68
|
+
jsi::Value isVisible(jsi::Runtime &rt) override {
|
|
69
|
+
static_assert(
|
|
70
|
+
bridging::getParameterCount(&T::isVisible) == 1,
|
|
71
|
+
"Expected isVisible(...) to have 1 parameters");
|
|
72
|
+
|
|
73
|
+
return bridging::callFromJs<jsi::Value>(
|
|
74
|
+
rt, &T::isVisible, jsInvoker_, instance_);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private:
|
|
78
|
+
friend class NativeRNBootSplashCxxSpec;
|
|
79
|
+
T *instance_;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
Delegate delegate_;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace facebook::react
|
|
@@ -2,24 +2,24 @@ package com.zoontek.rnbootsplash
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.app.Activity
|
|
5
|
+
import android.app.Application.ActivityLifecycleCallbacks
|
|
5
6
|
import android.content.res.Configuration
|
|
6
7
|
import android.os.Build
|
|
8
|
+
import android.os.Bundle
|
|
9
|
+
import android.os.Handler
|
|
10
|
+
import android.os.Looper
|
|
7
11
|
import android.util.TypedValue
|
|
8
12
|
import android.view.View
|
|
9
13
|
import android.view.ViewConfiguration
|
|
10
14
|
import android.view.ViewTreeObserver.OnPreDrawListener
|
|
11
|
-
|
|
12
15
|
import androidx.annotation.StyleRes
|
|
13
|
-
|
|
14
16
|
import com.facebook.common.logging.FLog
|
|
15
17
|
import com.facebook.react.bridge.Promise
|
|
16
18
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
17
19
|
import com.facebook.react.bridge.UiThreadUtil
|
|
18
20
|
import com.facebook.react.common.ReactConstants
|
|
19
21
|
import com.facebook.react.uimanager.PixelUtil
|
|
20
|
-
|
|
21
|
-
import java.util.Timer
|
|
22
|
-
import java.util.TimerTask
|
|
22
|
+
import java.util.concurrent.ConcurrentLinkedQueue
|
|
23
23
|
|
|
24
24
|
object RNBootSplashModuleImpl {
|
|
25
25
|
const val NAME = "RNBootSplash"
|
|
@@ -31,16 +31,12 @@ object RNBootSplashModuleImpl {
|
|
|
31
31
|
VISIBLE,
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
private
|
|
34
|
+
@StyleRes private var mThemeResId = -1
|
|
35
|
+
private val mPromiseQueue = ConcurrentLinkedQueue<Promise>()
|
|
35
36
|
private var mStatus = Status.HIDDEN
|
|
37
|
+
private var mSplashView: RNBootSplashView? = null
|
|
36
38
|
|
|
37
|
-
@StyleRes
|
|
38
|
-
private var mThemeResId = -1
|
|
39
|
-
|
|
40
|
-
private var mInitialDialog: RNBootSplashDialog? = null
|
|
41
|
-
private var mFadeOutDialog: RNBootSplashDialog? = null
|
|
42
|
-
|
|
43
|
-
internal fun init(activity: Activity?, @StyleRes themeResId: Int) {
|
|
39
|
+
internal fun init(mainActivity: Activity?, @StyleRes themeResId: Int) {
|
|
44
40
|
if (mThemeResId != -1) {
|
|
45
41
|
return FLog.w(
|
|
46
42
|
ReactConstants.TAG,
|
|
@@ -50,7 +46,7 @@ object RNBootSplashModuleImpl {
|
|
|
50
46
|
|
|
51
47
|
mThemeResId = themeResId
|
|
52
48
|
|
|
53
|
-
if (
|
|
49
|
+
if (mainActivity == null) {
|
|
54
50
|
return FLog.w(
|
|
55
51
|
ReactConstants.TAG,
|
|
56
52
|
"$NAME: Ignored initialization, current activity is null."
|
|
@@ -59,81 +55,85 @@ object RNBootSplashModuleImpl {
|
|
|
59
55
|
|
|
60
56
|
// Apply postBootSplashTheme
|
|
61
57
|
val typedValue = TypedValue()
|
|
62
|
-
val currentTheme =
|
|
58
|
+
val currentTheme = mainActivity.theme
|
|
63
59
|
|
|
64
60
|
if (currentTheme.resolveAttribute(R.attr.postBootSplashTheme, typedValue, true)) {
|
|
65
61
|
val finalThemeId = typedValue.resourceId
|
|
66
62
|
|
|
67
63
|
if (finalThemeId != 0) {
|
|
68
|
-
|
|
64
|
+
mainActivity.setTheme(finalThemeId)
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
67
|
|
|
72
|
-
// Keep the splash screen on-screen until
|
|
73
|
-
val contentView =
|
|
68
|
+
// Keep the splash screen on-screen until View is shown
|
|
69
|
+
val contentView = mainActivity.findViewById<View>(android.R.id.content)
|
|
74
70
|
mStatus = Status.INITIALIZING
|
|
75
71
|
|
|
76
|
-
contentView
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (mStatus == Status.INITIALIZING) {
|
|
81
|
-
return false
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
contentView
|
|
85
|
-
.viewTreeObserver
|
|
86
|
-
.removeOnPreDrawListener(this)
|
|
87
|
-
|
|
88
|
-
return true
|
|
72
|
+
contentView.viewTreeObserver.addOnPreDrawListener(object : OnPreDrawListener {
|
|
73
|
+
override fun onPreDraw(): Boolean {
|
|
74
|
+
if (mStatus == Status.INITIALIZING) {
|
|
75
|
+
return false
|
|
89
76
|
}
|
|
90
|
-
|
|
77
|
+
|
|
78
|
+
contentView.viewTreeObserver.removeOnPreDrawListener(this)
|
|
79
|
+
return true
|
|
80
|
+
}
|
|
81
|
+
})
|
|
91
82
|
|
|
92
83
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
93
84
|
// This is not called on Android 12 when activity is started using intent
|
|
94
85
|
// (Android studio / CLI / notification / widget…)
|
|
95
|
-
|
|
96
|
-
.splashScreen
|
|
97
|
-
.setOnExitAnimationListener { view ->
|
|
98
|
-
view.remove() // Remove it immediately, without animation
|
|
99
|
-
|
|
100
|
-
activity
|
|
101
|
-
.splashScreen
|
|
102
|
-
.clearOnExitAnimationListener()
|
|
103
|
-
}
|
|
104
|
-
}
|
|
86
|
+
val splashScreen = mainActivity.splashScreen
|
|
105
87
|
|
|
106
|
-
|
|
88
|
+
splashScreen.setOnExitAnimationListener { view ->
|
|
89
|
+
view.remove() // Remove it immediately, without animation
|
|
90
|
+
splashScreen.clearOnExitAnimationListener()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Mitigates race where splash exit listener may fire after activity stop (not a full fix)
|
|
94
|
+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.TIRAMISU) {
|
|
95
|
+
val application = mainActivity.application
|
|
96
|
+
|
|
97
|
+
application.registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
|
|
98
|
+
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
|
|
99
|
+
override fun onActivityDestroyed(activity: Activity) {}
|
|
100
|
+
override fun onActivityPaused(activity: Activity) {}
|
|
101
|
+
override fun onActivityResumed(activity: Activity) {}
|
|
102
|
+
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
|
|
103
|
+
override fun onActivityStarted(activity: Activity) {}
|
|
104
|
+
|
|
105
|
+
override fun onActivityStopped(activity: Activity) {
|
|
106
|
+
if (activity == mainActivity) {
|
|
107
|
+
runCatching { splashScreen.clearOnExitAnimationListener() }
|
|
108
|
+
application.unregisterActivityLifecycleCallbacks(this)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
107
114
|
|
|
108
115
|
UiThreadUtil.runOnUiThread {
|
|
109
|
-
|
|
116
|
+
mSplashView = RNBootSplashView(mainActivity, mThemeResId)
|
|
117
|
+
mStatus = Status.VISIBLE
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
private fun clearPromiseQueue() {
|
|
114
|
-
|
|
115
|
-
mPromiseQueue.shift()?.resolve(true)
|
|
116
|
-
}
|
|
122
|
+
generateSequence { mPromiseQueue.poll() }.forEach { it.resolve(true) }
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
private fun hideAndClearPromiseQueue(reactContext: ReactApplicationContext, fade: Boolean) {
|
|
120
126
|
UiThreadUtil.runOnUiThread {
|
|
121
127
|
val activity = reactContext.currentActivity
|
|
122
128
|
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
if (
|
|
130
|
+
mStatus == Status.INITIALIZING ||
|
|
131
|
+
activity == null ||
|
|
132
|
+
activity.isFinishing ||
|
|
133
|
+
activity.isDestroyed
|
|
127
134
|
) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
timer.schedule(object : TimerTask() {
|
|
131
|
-
override fun run() {
|
|
132
|
-
timer.cancel()
|
|
133
|
-
hideAndClearPromiseQueue(reactContext, fade)
|
|
134
|
-
}
|
|
135
|
-
}, 100)
|
|
136
|
-
|
|
135
|
+
Handler(Looper.getMainLooper())
|
|
136
|
+
.postDelayed({ hideAndClearPromiseQueue(reactContext, fade) }, 100)
|
|
137
137
|
return@runOnUiThread
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -143,39 +143,24 @@ object RNBootSplashModuleImpl {
|
|
|
143
143
|
|
|
144
144
|
if (mStatus == Status.HIDDEN) {
|
|
145
145
|
clearPromiseQueue()
|
|
146
|
-
return@runOnUiThread //
|
|
146
|
+
return@runOnUiThread // view is hidden
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
mStatus = Status.HIDING
|
|
150
150
|
|
|
151
|
-
val
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
clearPromiseQueue()
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
val initialDialogDismiss = {
|
|
159
|
-
mInitialDialog = null
|
|
160
|
-
mFadeOutDialog?.dismiss(fadeOutDialogDismiss) ?: fadeOutDialogDismiss()
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
mInitialDialog?.dismiss(initialDialogDismiss) ?: initialDialogDismiss()
|
|
151
|
+
val callback = {
|
|
152
|
+
mSplashView = null
|
|
153
|
+
mStatus = Status.HIDDEN
|
|
154
|
+
clearPromiseQueue()
|
|
164
155
|
}
|
|
165
156
|
|
|
166
|
-
|
|
167
|
-
// Create a new Dialog instance with fade out animation
|
|
168
|
-
mFadeOutDialog = RNBootSplashDialog(activity, mThemeResId, true)
|
|
169
|
-
mFadeOutDialog?.show(hideSequence)
|
|
170
|
-
} else {
|
|
171
|
-
mInitialDialog?.dismiss(hideSequence) ?: hideSequence()
|
|
172
|
-
}
|
|
157
|
+
mSplashView?.remove(fade, callback) ?: callback()
|
|
173
158
|
}
|
|
174
159
|
}
|
|
175
160
|
|
|
176
161
|
// From https://stackoverflow.com/a/61062773
|
|
177
|
-
|
|
178
|
-
|
|
162
|
+
val isSamsungOneUI4: Boolean by lazy {
|
|
163
|
+
runCatching {
|
|
179
164
|
val field = Build.VERSION::class.java.getDeclaredField("SEM_PLATFORM_INT")
|
|
180
165
|
val version = (field.getInt(null) - 90000) / 10000
|
|
181
166
|
version == 4
|
|
@@ -187,28 +172,23 @@ object RNBootSplashModuleImpl {
|
|
|
187
172
|
mThemeResId = -1
|
|
188
173
|
clearPromiseQueue()
|
|
189
174
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
mFadeOutDialog?.apply {
|
|
196
|
-
dismiss()
|
|
197
|
-
mFadeOutDialog = null
|
|
175
|
+
mSplashView?.let { view ->
|
|
176
|
+
view.animate().cancel()
|
|
177
|
+
view.remove(false)
|
|
178
|
+
mSplashView = null
|
|
198
179
|
}
|
|
199
180
|
}
|
|
200
181
|
|
|
201
182
|
fun getConstants(reactContext: ReactApplicationContext): Map<String, Any> {
|
|
202
183
|
val resources = reactContext.resources
|
|
203
|
-
val
|
|
204
|
-
|
|
205
|
-
val uiMode =
|
|
206
|
-
reactContext.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
|
184
|
+
val uiMode = reactContext.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
|
207
185
|
|
|
208
|
-
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
|
186
|
+
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
|
187
|
+
val statusBarHeightResId =
|
|
209
188
|
resources.getIdentifier("status_bar_height", "dimen", "android")
|
|
210
189
|
|
|
211
|
-
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
|
190
|
+
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
|
191
|
+
val navigationBarHeightResId =
|
|
212
192
|
resources.getIdentifier("navigation_bar_height", "dimen", "android")
|
|
213
193
|
|
|
214
194
|
val statusBarHeight = when {
|
|
@@ -223,16 +203,16 @@ object RNBootSplashModuleImpl {
|
|
|
223
203
|
else -> 0f
|
|
224
204
|
}
|
|
225
205
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
206
|
+
return buildMap {
|
|
207
|
+
put("darkModeEnabled", uiMode == Configuration.UI_MODE_NIGHT_YES)
|
|
208
|
+
put("logoSizeRatio", if (isSamsungOneUI4) 0.5 else 1.0)
|
|
209
|
+
put("navigationBarHeight", navigationBarHeight)
|
|
210
|
+
put("statusBarHeight", statusBarHeight)
|
|
211
|
+
}
|
|
232
212
|
}
|
|
233
213
|
|
|
234
214
|
fun hide(reactContext: ReactApplicationContext, fade: Boolean, promise: Promise) {
|
|
235
|
-
mPromiseQueue.
|
|
215
|
+
mPromiseQueue.add(promise)
|
|
236
216
|
hideAndClearPromiseQueue(reactContext, fade)
|
|
237
217
|
}
|
|
238
218
|
|
|
@@ -9,28 +9,19 @@ import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
|
9
9
|
class RNBootSplashPackage : TurboReactPackage() {
|
|
10
10
|
|
|
11
11
|
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
-
return
|
|
13
|
-
RNBootSplashModuleImpl.NAME -> RNBootSplashModule(reactContext)
|
|
14
|
-
else -> null
|
|
15
|
-
}
|
|
12
|
+
return if (name == RNBootSplashModuleImpl.NAME) RNBootSplashModule(reactContext) else null
|
|
16
13
|
}
|
|
17
14
|
|
|
18
|
-
override fun getReactModuleInfoProvider()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
22
|
-
|
|
23
|
-
val moduleInfo = ReactModuleInfo(
|
|
15
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
|
|
16
|
+
mapOf(
|
|
17
|
+
RNBootSplashModuleImpl.NAME to ReactModuleInfo(
|
|
24
18
|
RNBootSplashModuleImpl.NAME,
|
|
25
19
|
RNBootSplashModuleImpl.NAME,
|
|
26
20
|
false,
|
|
27
21
|
false,
|
|
28
22
|
false,
|
|
29
|
-
|
|
23
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
|
|
30
24
|
)
|
|
31
|
-
|
|
32
|
-
moduleInfos[RNBootSplashModuleImpl.NAME] = moduleInfo
|
|
33
|
-
moduleInfos
|
|
34
|
-
}
|
|
25
|
+
)
|
|
35
26
|
}
|
|
36
27
|
}
|