Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: xXDeonoXx/rn-manage-wallpaper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.1
Choose a base ref
...
head repository: xXDeonoXx/rn-manage-wallpaper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.4.0
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 2, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    sanjayankur31 Ankur Sinha
    Copy the full SHA
    4e0a6e6 View commit details
  2. chore: release 0.4.0

    xXDeonoXx committed May 2, 2022
    Copy the full SHA
    467a601 View commit details
Showing with 38 additions and 4 deletions.
  1. +37 −3 README.md
  2. +1 −1 package.json
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,18 +5,52 @@ this package allows you to access wallpaper tools from native apis
## Installation

```sh
npm install rn-manage-wallpaper
yarn add rn-manage-wallpaper
```

## After install run this to link the packages.
```sh
yarn android
```

## permissions

this package needs the following permissions:

```xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

## Usage

WallpaperManager has one function called setWallpaper that receives 2 arguments, file uri and a flag that indicates whenever it will be set as lock screen or system screen, [FLAG_LOCK](https://developer.android.com/reference/android/app/WallpaperManager#FLAG_LOCK) and [FLAG_SYSTEM](https://developer.android.com/reference/android/app/WallpaperManager#FLAG_SYSTEM) for reference, you can get their values using the getConstants function.

## Example

in this example i use RNFetchBlob to donwload a web image and use the cache file path to define the wallpaper

```js
import WallpaperManager from 'rn-manage-wallpaper';

// ...

const result = await WallpaperManager.multiply(3, 7);
```
const FLAG_CONSTANTS = WallpaperManager.getConstants();
RNFetchBlob.config({
// add this option that makes response data to be stored as a file,
fileCache: true,
})
.fetch('GET', image.url, {
//some headers ..
})
.then(res => {
try {
WallpaperManager.setWallpaper(`${res.path()}`, FLAG_CONSTANTS.FLAG_SYSTEM);
} catch (error) {
console.log(error);
}
});
```

## Contributing

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-manage-wallpaper",
"version": "0.3.1",
"version": "0.4.0",
"description": "this package allows you to access wallpaper tools from native apis",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",