react-native-nitro-wallpaper 1.1.1 → 1.1.4
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/build.gradle +1 -1
- package/android/src/main/java/com/margelo/nitro/reactnativenitrowallpaper/WallpaperSet.kt +15 -2
- package/android/src/main/java/com/margelo/nitro/reactnativenitrowallpaper/WallpaperSetPackage.kt +8 -7
- package/nitrogen/generated/android/c++/JHybridWallpaperSetSpec.cpp +9 -1
- package/nitrogen/generated/android/c++/JHybridWallpaperSetSpec.hpp +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativenitrowallpaper/HybridWallpaperSetSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativenitrowallpaper/reactnativenitrowallpaperOnLoad.kt +1 -1
- package/nitrogen/generated/android/reactnativenitrowallpaper+autolinking.cmake +1 -1
- package/nitrogen/generated/android/reactnativenitrowallpaper+autolinking.gradle +1 -1
- package/nitrogen/generated/android/reactnativenitrowallpaperOnLoad.cpp +1 -1
- package/nitrogen/generated/android/reactnativenitrowallpaperOnLoad.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridWallpaperSetSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridWallpaperSetSpec.hpp +1 -1
- package/package.json +9 -5
- package/react-native.config.js +0 -12
package/android/build.gradle
CHANGED
|
@@ -43,7 +43,7 @@ android {
|
|
|
43
43
|
externalNativeBuild {
|
|
44
44
|
cmake {
|
|
45
45
|
cppFlags "-frtti -fexceptions -Wall -fstack-protector-all"
|
|
46
|
-
arguments "-DANDROID_STL=c++_shared"
|
|
46
|
+
arguments "-DANDROID_STL=c++_shared"
|
|
47
47
|
abiFilters (*reactNativeArchitectures())
|
|
48
48
|
|
|
49
49
|
buildTypes {
|
|
@@ -6,6 +6,7 @@ import android.app.WallpaperManager
|
|
|
6
6
|
import android.graphics.Bitmap
|
|
7
7
|
import android.graphics.BitmapFactory
|
|
8
8
|
import android.net.Uri
|
|
9
|
+
import android.content.Context
|
|
9
10
|
import com.margelo.nitro.core.Promise
|
|
10
11
|
import java.net.URL
|
|
11
12
|
|
|
@@ -13,9 +14,21 @@ import java.net.URL
|
|
|
13
14
|
class WallpaperSet : HybridWallpaperSetSpec() {
|
|
14
15
|
override fun setWallpaper(image: String, location: Double): Promise<Unit> {
|
|
15
16
|
val promise = Promise<Unit>()
|
|
16
|
-
|
|
17
|
+
// Try to get context from package first, then fallback to current application
|
|
18
|
+
var context: Context? = WallpaperSetPackage.context
|
|
17
19
|
if (context == null) {
|
|
18
|
-
|
|
20
|
+
// Fallback: try to get context from current application
|
|
21
|
+
try {
|
|
22
|
+
val activityThread = Class.forName("android.app.ActivityThread")
|
|
23
|
+
val currentApplication = activityThread.getMethod("currentApplication").invoke(null) as? android.app.Application
|
|
24
|
+
context = currentApplication?.applicationContext
|
|
25
|
+
} catch (e: Exception) {
|
|
26
|
+
// Fallback failed, context is still null
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (context == null) {
|
|
31
|
+
promise.reject(Exception("Context not initialized. Make sure the package is properly registered in your MainApplication."))
|
|
19
32
|
return promise
|
|
20
33
|
}
|
|
21
34
|
|
package/android/src/main/java/com/margelo/nitro/reactnativenitrowallpaper/WallpaperSetPackage.kt
CHANGED
|
@@ -9,15 +9,14 @@ import android.util.Log
|
|
|
9
9
|
|
|
10
10
|
class WallpaperSetPackage : BaseReactPackage() {
|
|
11
11
|
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
// Set context here for Nitro modules
|
|
13
|
+
if (context == null) {
|
|
14
|
+
context = reactContext.applicationContext
|
|
15
|
+
Log.d("WallpaperSetPackage", "Context set in getModule")
|
|
16
|
+
}
|
|
12
17
|
return null
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule> {
|
|
16
|
-
Log.d("WallpaperSetPackage", "createNativeModules called!")
|
|
17
|
-
context = reactContext
|
|
18
|
-
return super.createNativeModules(reactContext) as MutableList<NativeModule>
|
|
19
|
-
}
|
|
20
|
-
|
|
21
20
|
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
22
21
|
return ReactModuleInfoProvider { HashMap() }
|
|
23
22
|
}
|
|
@@ -25,7 +24,9 @@ class WallpaperSetPackage : BaseReactPackage() {
|
|
|
25
24
|
companion object {
|
|
26
25
|
var context: android.content.Context? = null
|
|
27
26
|
init {
|
|
28
|
-
|
|
27
|
+
// Initialize the native Nitro module early - this registers the HybridObject in the registry
|
|
28
|
+
// This must be called before any JS code tries to use the module
|
|
29
|
+
reactnativenitrowallpaperOnLoad.initializeNative()
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// JHybridWallpaperSetSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "JHybridWallpaperSetSpec.hpp"
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
#include <NitroModules/Promise.hpp>
|
|
13
13
|
#include <NitroModules/JPromise.hpp>
|
|
14
|
+
#include <NitroModules/JUnit.hpp>
|
|
14
15
|
#include <string>
|
|
15
16
|
|
|
16
17
|
namespace margelo::nitro::reactnativenitrowallpaper {
|
|
@@ -30,6 +31,13 @@ namespace margelo::nitro::reactnativenitrowallpaper {
|
|
|
30
31
|
return method(_javaPart);
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
bool JHybridWallpaperSetSpec::equals(const std::shared_ptr<HybridObject>& other) {
|
|
35
|
+
if (auto otherCast = std::dynamic_pointer_cast<JHybridWallpaperSetSpec>(other)) {
|
|
36
|
+
return _javaPart == otherCast->_javaPart;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
void JHybridWallpaperSetSpec::dispose() noexcept {
|
|
34
42
|
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
35
43
|
method(_javaPart);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridWallpaperSetSpec.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -40,6 +40,7 @@ namespace margelo::nitro::reactnativenitrowallpaper {
|
|
|
40
40
|
|
|
41
41
|
public:
|
|
42
42
|
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
43
44
|
void dispose() noexcept override;
|
|
44
45
|
std::string toString() override;
|
|
45
46
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridWallpaperSetSpec.kt
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.reactnativenitrowallpaper
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// reactnativenitrowallpaperOnLoad.kt
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.reactnativenitrowallpaper
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# reactnativenitrowallpaper+autolinking.cmake
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a CMake file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// reactnativenitrowallpaper+autolinking.gradle
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// reactnativenitrowallpaperOnLoad.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#ifndef BUILDING_REACTNATIVENITROWALLPAPER_WITH_GENERATED_CMAKE_PROJECT
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridWallpaperSetSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridWallpaperSetSpec.hpp"
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-wallpaper",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Set wallpaper on React Native (Android only)",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"react-native": {
|
|
8
|
+
"android": {
|
|
9
|
+
"packageInstance": "new com.margelo.nitro.reactnativenitrowallpaper.WallpaperSetPackage()"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
7
12
|
"exports": {
|
|
8
13
|
".": {
|
|
9
14
|
"source": "./src/index.tsx",
|
|
@@ -19,7 +24,6 @@
|
|
|
19
24
|
"cpp",
|
|
20
25
|
"nitrogen",
|
|
21
26
|
"nitro.json",
|
|
22
|
-
"react-native.config.js",
|
|
23
27
|
"!android/build",
|
|
24
28
|
"!android/gradle",
|
|
25
29
|
"!android/gradlew",
|
|
@@ -86,12 +90,12 @@
|
|
|
86
90
|
"eslint-plugin-prettier": "^5.5.4",
|
|
87
91
|
"jest": "^29.7.0",
|
|
88
92
|
"lefthook": "^2.0.3",
|
|
89
|
-
"nitrogen": "^0.
|
|
93
|
+
"nitrogen": "^0.33.0",
|
|
90
94
|
"prettier": "^2.8.8",
|
|
91
95
|
"react": "19.2.0",
|
|
92
96
|
"react-native": "0.83.0",
|
|
93
97
|
"react-native-builder-bob": "^0.40.17",
|
|
94
|
-
"react-native-nitro-modules": "^0.
|
|
98
|
+
"react-native-nitro-modules": "^0.33.0",
|
|
95
99
|
"release-it": "^19.0.4",
|
|
96
100
|
"turbo": "^2.5.6",
|
|
97
101
|
"typescript": "^5.9.2"
|
|
@@ -99,7 +103,7 @@
|
|
|
99
103
|
"peerDependencies": {
|
|
100
104
|
"react": "*",
|
|
101
105
|
"react-native": "*",
|
|
102
|
-
"react-native-nitro-modules": "^0.
|
|
106
|
+
"react-native-nitro-modules": "^0.33.0"
|
|
103
107
|
},
|
|
104
108
|
"workspaces": [
|
|
105
109
|
"example"
|
package/react-native.config.js
DELETED