react-native-nitro-wallpaper 1.0.0 → 1.1.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/README.md +6 -1
- package/android/build.gradle +2 -2
- package/android/gradle.properties +3 -2
- package/android/src/main/java/com/margelo/nitro/reactnativenitrowallpaper/WallpaperSet.kt +6 -2
- package/lib/module/index.js +18 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/WallpaperSet.nitro.d.ts +1 -1
- package/lib/typescript/src/WallpaperSet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridWallpaperSetSpec.cpp +4 -4
- package/nitrogen/generated/android/c++/JHybridWallpaperSetSpec.hpp +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativenitrowallpaper/HybridWallpaperSetSpec.kt +2 -2
- 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 +2 -2
- package/package.json +1 -1
- package/src/WallpaperSet.nitro.ts +1 -1
- package/src/index.tsx +21 -2
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ No additional setup required. The library will be automatically linked.
|
|
|
21
21
|
```js
|
|
22
22
|
import { WallpaperSet } from 'react-native-nitro-wallpaper';
|
|
23
23
|
|
|
24
|
-
// Set wallpaper from URL
|
|
24
|
+
// Set wallpaper from URL (Sets both Home and Lock screens by default)
|
|
25
25
|
await WallpaperSet.setWallpaper('https://example.com/image.jpg');
|
|
26
26
|
|
|
27
27
|
// Set wallpaper from local file path
|
|
@@ -32,6 +32,11 @@ await WallpaperSet.setWallpaper('file:///storage/emulated/0/Pictures/wallpaper.j
|
|
|
32
32
|
|
|
33
33
|
// Set wallpaper from content URI
|
|
34
34
|
await WallpaperSet.setWallpaper('content://media/external/images/media/123');
|
|
35
|
+
|
|
36
|
+
// Set specific screen
|
|
37
|
+
await WallpaperSet.setWallpaper('https://example.com/image.jpg', 'home'); // Home screen only
|
|
38
|
+
await WallpaperSet.setWallpaper('https://example.com/image.jpg', 'lock'); // Lock screen only
|
|
39
|
+
await WallpaperSet.setWallpaper('https://example.com/image.jpg', 'both'); // Both screens
|
|
35
40
|
```
|
|
36
41
|
|
|
37
42
|
### Example
|
package/android/build.gradle
CHANGED
|
@@ -24,7 +24,7 @@ apply plugin: "com.android.library"
|
|
|
24
24
|
apply plugin: "kotlin-android"
|
|
25
25
|
apply from: '../nitrogen/generated/android/reactnativenitrowallpaper+autolinking.gradle'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
|
|
29
29
|
def getExtOrIntegerDefault(name) {
|
|
30
30
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["WallpaperSet_" + name]).toInteger()
|
|
@@ -123,7 +123,7 @@ repositories {
|
|
|
123
123
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
124
124
|
|
|
125
125
|
dependencies {
|
|
126
|
-
|
|
126
|
+
compileOnly "com.facebook.react:react-android"
|
|
127
127
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
128
128
|
implementation project(":react-native-nitro-modules")
|
|
129
129
|
}
|
|
@@ -11,7 +11,7 @@ import java.net.URL
|
|
|
11
11
|
|
|
12
12
|
@DoNotStrip
|
|
13
13
|
class WallpaperSet : HybridWallpaperSetSpec() {
|
|
14
|
-
override fun setWallpaper(image: String): Promise<Unit> {
|
|
14
|
+
override fun setWallpaper(image: String, location: Double): Promise<Unit> {
|
|
15
15
|
val promise = Promise<Unit>()
|
|
16
16
|
val context = WallpaperSetPackage.context
|
|
17
17
|
if (context == null) {
|
|
@@ -41,7 +41,11 @@ class WallpaperSet : HybridWallpaperSetSpec() {
|
|
|
41
41
|
throw Exception("Failed to decode bitmap from: $image")
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
45
|
+
wallpaperManager.setBitmap(bitmap, null, true, location.toInt())
|
|
46
|
+
} else {
|
|
47
|
+
wallpaperManager.setBitmap(bitmap)
|
|
48
|
+
}
|
|
45
49
|
promise.resolve(Unit)
|
|
46
50
|
} catch (e: Throwable) {
|
|
47
51
|
promise.reject(e)
|
package/lib/module/index.js
CHANGED
|
@@ -4,11 +4,27 @@ import { NitroModules } from 'react-native-nitro-modules';
|
|
|
4
4
|
import { Platform } from 'react-native';
|
|
5
5
|
const WallpaperSetNative = NitroModules.createHybridObject('WallpaperSet');
|
|
6
6
|
export const WallpaperSet = {
|
|
7
|
-
setWallpaper: async image => {
|
|
7
|
+
setWallpaper: async (image, location = 'both') => {
|
|
8
8
|
if (Platform.OS === 'ios') {
|
|
9
9
|
throw new Error('react-native-nitro-wallpaper is Android-only. iOS is not supported.');
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
// Map location string to Android flags
|
|
12
|
+
// FLAG_SYSTEM = 1
|
|
13
|
+
// FLAG_LOCK = 2
|
|
14
|
+
// FLAG_SYSTEM | FLAG_LOCK = 3
|
|
15
|
+
let locationFlag = 3;
|
|
16
|
+
switch (location) {
|
|
17
|
+
case 'home':
|
|
18
|
+
locationFlag = 1;
|
|
19
|
+
break;
|
|
20
|
+
case 'lock':
|
|
21
|
+
locationFlag = 2;
|
|
22
|
+
break;
|
|
23
|
+
case 'both':
|
|
24
|
+
locationFlag = 3;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return WallpaperSetNative.setWallpaper(image, locationFlag);
|
|
12
28
|
}
|
|
13
29
|
};
|
|
14
30
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NitroModules","Platform","WallpaperSetNative","createHybridObject","WallpaperSet","setWallpaper","image","OS","Error"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SAASC,QAAQ,QAAQ,cAAc;AAGvC,MAAMC,kBAAkB,GACtBF,YAAY,CAACG,kBAAkB,CAAmB,cAAc,CAAC;AAEnE,OAAO,MAAMC,YAAY,GAAG;EAC1BC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"names":["NitroModules","Platform","WallpaperSetNative","createHybridObject","WallpaperSet","setWallpaper","image","location","OS","Error","locationFlag"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SAASC,QAAQ,QAAQ,cAAc;AAGvC,MAAMC,kBAAkB,GACtBF,YAAY,CAACG,kBAAkB,CAAmB,cAAc,CAAC;AAEnE,OAAO,MAAMC,YAAY,GAAG;EAC1BC,YAAY,EAAE,MAAAA,CACZC,KAAa,EACbC,QAAkC,GAAG,MAAM,KACzB;IAClB,IAAIN,QAAQ,CAACO,EAAE,KAAK,KAAK,EAAE;MACzB,MAAM,IAAIC,KAAK,CACb,qEACF,CAAC;IACH;IACA;IACA;IACA;IACA;IACA,IAAIC,YAAY,GAAG,CAAC;IACpB,QAAQH,QAAQ;MACd,KAAK,MAAM;QACTG,YAAY,GAAG,CAAC;QAChB;MACF,KAAK,MAAM;QACTA,YAAY,GAAG,CAAC;QAChB;MACF,KAAK,MAAM;QACTA,YAAY,GAAG,CAAC;QAChB;IACJ;IACA,OAAOR,kBAAkB,CAACG,YAAY,CAACC,KAAK,EAAEI,YAAY,CAAC;EAC7D;AACF,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,6 @@ import type { HybridObject } from 'react-native-nitro-modules';
|
|
|
2
2
|
export interface WallpaperSet extends HybridObject<{
|
|
3
3
|
android: 'kotlin';
|
|
4
4
|
}> {
|
|
5
|
-
setWallpaper(image: string): Promise<void>;
|
|
5
|
+
setWallpaper(image: string, location: number): Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=WallpaperSet.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WallpaperSet.nitro.d.ts","sourceRoot":"","sources":["../../../src/WallpaperSet.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,YAAa,SAAQ,YAAY,CAAC;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACvE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"WallpaperSet.nitro.d.ts","sourceRoot":"","sources":["../../../src/WallpaperSet.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,YAAa,SAAQ,YAAY,CAAC;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACvE,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;0BAEd,MAAM,aACH,MAAM,GAAG,MAAM,GAAG,MAAM,KACjC,OAAO,CAAC,IAAI,CAAC;CAwBjB,CAAC"}
|
|
@@ -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 © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "JHybridWallpaperSetSpec.hpp"
|
|
@@ -45,9 +45,9 @@ namespace margelo::nitro::reactnativenitrowallpaper {
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
// Methods
|
|
48
|
-
std::shared_ptr<Promise<void>> JHybridWallpaperSetSpec::setWallpaper(const std::string& image) {
|
|
49
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* image */)>("setWallpaper");
|
|
50
|
-
auto __result = method(_javaPart, jni::make_jstring(image));
|
|
48
|
+
std::shared_ptr<Promise<void>> JHybridWallpaperSetSpec::setWallpaper(const std::string& image, double location) {
|
|
49
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* image */, double /* location */)>("setWallpaper");
|
|
50
|
+
auto __result = method(_javaPart, jni::make_jstring(image), location);
|
|
51
51
|
return [&]() {
|
|
52
52
|
auto __promise = Promise<void>::create();
|
|
53
53
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
@@ -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 © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -54,7 +54,7 @@ namespace margelo::nitro::reactnativenitrowallpaper {
|
|
|
54
54
|
|
|
55
55
|
public:
|
|
56
56
|
// Methods
|
|
57
|
-
std::shared_ptr<Promise<void>> setWallpaper(const std::string& image) override;
|
|
57
|
+
std::shared_ptr<Promise<void>> setWallpaper(const std::string& image, double location) override;
|
|
58
58
|
|
|
59
59
|
private:
|
|
60
60
|
friend HybridBase;
|
|
@@ -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 © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.reactnativenitrowallpaper
|
|
@@ -48,7 +48,7 @@ abstract class HybridWallpaperSetSpec: HybridObject() {
|
|
|
48
48
|
// Methods
|
|
49
49
|
@DoNotStrip
|
|
50
50
|
@Keep
|
|
51
|
-
abstract fun setWallpaper(image: String): Promise<Unit>
|
|
51
|
+
abstract fun setWallpaper(image: String, location: Double): Promise<Unit>
|
|
52
52
|
|
|
53
53
|
private external fun initHybrid(): HybridData
|
|
54
54
|
|
|
@@ -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 © 2026 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 © 2026 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 © 2026 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 © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#ifndef BUILDING_REACTNATIVENITROWALLPAPER_WITH_GENERATED_CMAKE_PROJECT
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// reactnativenitrowallpaperOnLoad.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 © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include <jni.h>
|
|
@@ -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 © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridWallpaperSetSpec.hpp"
|
|
@@ -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 © 2026 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -49,7 +49,7 @@ namespace margelo::nitro::reactnativenitrowallpaper {
|
|
|
49
49
|
|
|
50
50
|
public:
|
|
51
51
|
// Methods
|
|
52
|
-
virtual std::shared_ptr<Promise<void>> setWallpaper(const std::string& image) = 0;
|
|
52
|
+
virtual std::shared_ptr<Promise<void>> setWallpaper(const std::string& image, double location) = 0;
|
|
53
53
|
|
|
54
54
|
protected:
|
|
55
55
|
// Hybrid Setup
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -6,12 +6,31 @@ const WallpaperSetNative =
|
|
|
6
6
|
NitroModules.createHybridObject<WallpaperSetSpec>('WallpaperSet');
|
|
7
7
|
|
|
8
8
|
export const WallpaperSet = {
|
|
9
|
-
setWallpaper: async (
|
|
9
|
+
setWallpaper: async (
|
|
10
|
+
image: string,
|
|
11
|
+
location: 'home' | 'lock' | 'both' = 'both'
|
|
12
|
+
): Promise<void> => {
|
|
10
13
|
if (Platform.OS === 'ios') {
|
|
11
14
|
throw new Error(
|
|
12
15
|
'react-native-nitro-wallpaper is Android-only. iOS is not supported.'
|
|
13
16
|
);
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
// Map location string to Android flags
|
|
19
|
+
// FLAG_SYSTEM = 1
|
|
20
|
+
// FLAG_LOCK = 2
|
|
21
|
+
// FLAG_SYSTEM | FLAG_LOCK = 3
|
|
22
|
+
let locationFlag = 3;
|
|
23
|
+
switch (location) {
|
|
24
|
+
case 'home':
|
|
25
|
+
locationFlag = 1;
|
|
26
|
+
break;
|
|
27
|
+
case 'lock':
|
|
28
|
+
locationFlag = 2;
|
|
29
|
+
break;
|
|
30
|
+
case 'both':
|
|
31
|
+
locationFlag = 3;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
return WallpaperSetNative.setWallpaper(image, locationFlag);
|
|
16
35
|
},
|
|
17
36
|
};
|