Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarCruz committed May 20, 2019
1 parent 0d868d3 commit 63d49f5
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default": true,
"line-length": false,
"no-duplicate-header": { "siblings_only": true },
"no-inline-html": false
}
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,75 @@

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.1.0] - 2019-05-20

### Changed

- Updated Android Tools to v28.x
- Using gradle 4.10.2

### Fixed

- Minor errors in build.gradle

### Added

- Markdownlint config
- Ko-fi link

## [2.0.1] - 2018-10-09

### Fixed

- Fix error in build.gradle

## [2.0.0] - 2018-10-09

This is the first version for Gradle 4.4

### Added

- Runtime check in debug mode for the type of values to store.

### Changed

- The id of `watchKeys` and `clearWatch` is number, the callback returns void.

## [1.0.2] - 2018-09-17

### Changed

- The changelog follows the format on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Simplifies the reading of variables in android/build.gradle

### Fixed

- The callback of `watchKeys` is not called.

## [1.0.1] - 2018-03-19

### Fixed

- Missing google repository in android/gradle (for development).

## [1.0.0] - 2018-03-19

### Added

- Flow types (not sure if correctly).

### Changed

- The default `buildToolsVersion` was changed 26.0.3 and `compileSdkVersion`/`targetSdkVersion` to 26.
- Better support for `long` & `double` values (the range of `long` is still limited by the RN Bridge).

### Removed

- react-native from peerDependencies, since this library must work in versions prior to 0.50.

## [0.2.0] 2018-03-19

### Changed

- Changed minSdkVersion version to 16 - Thanks to @wayne1203
- The preferences file is openning only when used.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ React Native `Settings` module for both Android & iOS.

If this library has helped you, don't forget to give it a star :star2:

## IMPORTANT

v2.0 works with Gradle 4.4, the default in React Native 0.57. If you are using Gradle 3.x please use react-native-cross-settings 1.0.2
## Important

v2.1.0 works with Gradle 4.10.x, the default in React Native 0.58. If you are using Gradle 3.x please use react-native-cross-settings 1.0.2

## Setup

Expand Down Expand Up @@ -101,18 +100,18 @@ Settings.set({ myArray: JSON.stringify([1,2,3]) })
const myArray = JSON.parse(Settings.get('myArray') || '[]')
```


## Support my Work

I'm a full-stack developer with more than 20 year of experience and I try to share most of my work for free and help others, but this takes a significant amount of time and effort so, if you like my work, please consider...

[![Buy me a Coffee][bmc-image]][bmc-url]
<!-- markdownlint-disable MD033 -->
[<img src="https://amarcruz.github.io/images/kofi_blue.png" height="36" title="Support Me on Ko-fi" />][kofi-url]
<!-- markdownlint-enable MD033 -->

Feedback, PRs stars, and smiles are also welcome :)
Of course, feedback, PRs, and stars are also welcome 🙃

Thanks for your support!


## License

The [MIT License](LICENSE) (MIT)
Expand All @@ -122,4 +121,4 @@ The [MIT License](LICENSE) (MIT)
[license-image]: https://img.shields.io/npm/l/express.svg
[license-url]: https://github.com/aMarCruz/react-native-cross-settings/blob/master/LICENSE
[bmc-image]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png
[bmc-url]: https://www.buymeacoffee.com/aMarCruz
[kofi-url]: https://ko-fi.com/C0C7LF7I
18 changes: 9 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import groovy.json.JsonSlurper

// dynamically retrieve version from package.json
def getPackageVersion() {
return new JsonSlurper().parse(file('../package.json'), 'utf-8').version
new JsonSlurper().parse(file('../package.json'), 'utf-8').version
}

def getExtValue(prop, fallback) {
return rootProject.ext.hasProperty(prop) ? rootProject.ext.get(prop) : fallback
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def _buildToolsVersion = getExtValue('buildToolsVersion', '27.0.3')
def _compileSdkVersion = getExtValue('compileSdkVersion', 27)
def _targetSdkVersion = getExtValue('targetSdkVersion', 27)
def _buildToolsVersion = getExtValue('buildToolsVersion', '28.0.3')
def _compileSdkVersion = getExtValue('compileSdkVersion', 28)
def _targetSdkVersion = getExtValue('targetSdkVersion', 28)
def _minSdkVersion = getExtValue('minSdkVersion', 16)

buildscript {
Expand All @@ -25,7 +25,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.3.1'
}
}

Expand All @@ -38,15 +38,15 @@ android {
defaultConfig {
minSdkVersion _minSdkVersion
targetSdkVersion _targetSdkVersion
versionCode 2
versionCode 3
versionName getPackageVersion()
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,8 @@ public void setValues(final ReadableMap map) {
private void storeNumber(final SharedPreferences.Editor editor, final String key, final double number) {
// Can be long, float, or double.
if (number == (int) number || Double.isNaN(number)) {
Log.v(TAG, "Saving " + key + " as int.");
editor.putInt(key, (int) number);
} else {
Log.v(TAG, "Saving " + key + " as double.");
editor.putLong(key, Double.doubleToRawLongBits(number));
}
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-cross-settings",
"description": "React Native `Settings` module for both Android & iOS.",
"version": "2.0.1",
"version": "2.1.0",
"license": "MIT",
"main": "./index.js",
"typings": "./index.d.ts",
Expand Down Expand Up @@ -30,6 +30,6 @@
"invariant": "^2.2.3"
},
"peerDependencies": {
"react-native": ">=0.55.0"
"react-native": ">=0.57.0"
}
}
8 changes: 8 additions & 0 deletions settings-android.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const invariant = require('invariant');

const subscriptions = [];

const isObject = (obj) => {
return obj && typeof obj === 'object' && !Array.isArray(obj) && !(obj instanceof Date)
}

const checkValues = (obj) => {
const keys = Object.keys(obj)

Expand Down Expand Up @@ -44,6 +48,10 @@ const Settings = {
},

set(settings) {
invariant(
isObject(settings),
'Settings for Android expect a plain JavaScript object.'
)
invariant(
checkValues(settings),
'Settings for Android only supports number, string and boolean.'
Expand Down

0 comments on commit 63d49f5

Please sign in to comment.