Skip to content

Commit

Permalink
Merged in release/15.2.0 (pull request #63)
Browse files Browse the repository at this point in the history
Release/15.2.0
  • Loading branch information
mstanic-shake committed Apr 19, 2022
2 parents b68b8d4 + 84019b3 commit 9e807fa
Show file tree
Hide file tree
Showing 22 changed files with 720 additions and 954 deletions.
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,51 @@ Execute the npm install command in your terminal:
npm install @shakebugs/react-native-shake
```

If you are using a React Native version 0.60 or greater, you should also run add command:
Install pods from the project root directory:
```bash
react-native add-shake
cd ios && pod install && cd ..
```

If you are using a React Native version older than 0.60, you should instead run link command:
```bash
react-native link @shakebugs/react-native-shake
### Set compileSdkVersion version in the build.gradle file

Since Shake requires `compileSdkVersion` 29 or greater, verify that `compileSdkVersion` is correctly set in the *build.gradle* file:

```groovy title="android/build.gradle"
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
}
}
```

Install pods from the project root directory:
```bash
cd ios && pod install && cd ..
### Set multidexEnabled flag in the build.gradle file

If you do not have *multiDexEnabled* flag set, update app-level *build.gradle* like below:

```groovy title="app/build.gradle"
defaultConfig {
applicationId "com.shakebugs.react.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0.0"
multiDexEnabled true
}
```

### Start Shake

Call `Shake.start()` method in the *index.js* file.

```javascript title="index.js"
Expand Down
78 changes: 1 addition & 77 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def safeExtGet(prop, fallback) {
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
Expand All @@ -45,9 +44,6 @@ rootProject.allprojects {
}
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
Expand Down Expand Up @@ -79,77 +75,5 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
api "$System.env.ANDROID_DEPENDENCY:15.1.+"
}

def configureReactNativePom(def pom) {
def packageJson = new JsonSlurper().parseText(file('../package.json').text)
pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.shakebugs.react"
description packageJson.description
url packageJson.repository.baseUrl

licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}

developers {
developer {
id packageJson.author.username
name packageJson.author.name
}
}
}
}

afterEvaluate { project ->
// some Gradle build hooks ref:
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
classpath += files(project.getConfigurations().getByName('compile').asList())
include '**/*.java'
}

task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}

android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()

task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir
}
}

artifacts {
archives androidSourcesJar
archives androidJavadocJar
}

task installArchives(type: Upload) {
configuration = configurations.archives
repositories.mavenDeployer {
// Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://${projectDir}/../android/maven"
configureReactNativePom pom
}
}
api "$System.env.ANDROID_DEPENDENCY:15.2.+"
}
9 changes: 7 additions & 2 deletions android/src/main/java/com/shakebugs/react/ShakeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ public void run() {
}

@ReactMethod
public void setEnabled(final boolean enabled) {
public void isUserFeedbackEnabled(Promise promise) {
promise.resolve(Shake.isUserFeedbackEnabled());
}

@ReactMethod
public void setUserFeedbackEnabled(final boolean enabled) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Shake.setEnabled(enabled);
Shake.setUserFeedbackEnabled(enabled);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.shakebugs.react.example;

import android.view.MotionEvent;

import com.facebook.react.ReactActivity;
import com.shakebugs.shake.Shake;

public class MainActivity extends ReactActivity {
/**
Expand All @@ -14,10 +11,4 @@ public class MainActivity extends ReactActivity {
protected String getMainComponentName() {
return "example";
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
Shake.handleTouchEvent(ev, this);
return super.dispatchTouchEvent(ev);
}
}
5 changes: 3 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Mar 16 12:03:47 CET 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading

0 comments on commit 9e807fa

Please sign in to comment.