Skip to content

Commit

Permalink
Merge pull request #7 from rebythecode/imports-gradle
Browse files Browse the repository at this point in the history
refactor build.gradle
  • Loading branch information
sejoDjoseon authored Dec 16, 2021
2 parents f7ceb9c + 242b672 commit b48875c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 88 deletions.
30 changes: 1 addition & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Linking the package manually is not required anymore with [Autolinking](https://

Include the library in your `android/app/build.gradle`:

`implementation 'com.kustomer.chat:ui:2.9.1'`
`implementation 'com.kustomer.chat:ui:2.9.+'`

### iOS

Expand Down Expand Up @@ -54,34 +54,6 @@ public class MainApplication extends Application implements ReactApplication {
}
```

Add the following permissions to your `AndroidManifest.xml`:

```xml
<!--Required to make network requests-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<!--Required to take a picture and send as an attachment over chat-->

<uses-permission android:name="android.permission.CAMERA"/>

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
<intent>
<action android:name="android.intent.action.GET_CONTENT" />

<data android:mimeType="*/*" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />

<data android:mimeType="*/*" />
</intent>
</queries>
```

To customize Kustomer's theme, add a new style in `colors.xml` overwriting the values you want to replace, for example:

```xml
Expand Down
79 changes: 22 additions & 57 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,65 +1,34 @@
// android/build.gradle

// based on:
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle

def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 28
def LIFECYLCE_VERSION = "2.3.1"

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven'
configurations.maybeCreate("default")

buildscript {
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeKustomer_' + name]
}
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
if (project == rootProject) {
repositories {
google()
jcenter()
maven {
url 'https://kustomer.bintray.com/android'
}
}
ext.safeExtGet = {prop, fallback ->
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

ext {
kotlinVersion = '1.4.21'
gradleVersion = '4.1.2'
buildToolsVersion = "29.0.0"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
}

dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20"
}
} else {
repositories {
jcenter()
maven {
url 'https://kustomer.bintray.com/android'
}
}
repositories {
google()
mavenCentral()
}

dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
}
dependencies {
classpath "com.android.tools.build:gradle:${safeExtGet('gradleVersion', DEFAULT_GRADLE_VERSION)}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', DEFAULT_KOTLIN_VERSION)}"
}
}

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

android {
Expand Down Expand Up @@ -95,12 +64,8 @@ repositories {
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50"
implementation 'com.kustomer.chat:ui:2.9.2'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$LIFECYLCE_VERSION"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$LIFECYLCE_VERSION"
implementation 'com.kustomer.chat:ui:2.9.+'
}

def configureReactNativePom(def pom) {
Expand Down
6 changes: 6 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DEFAULT_KOTLIN_VERSION=1.4.21
DEFAULT_GRADLE_VERSION=4.1.2
DEFAULT_COMPILE_SDK_VERSION=29
DEFAULT_BUILD_TOOLS_VERSION =29.0.0
DEFAULT_MIN_SDK_VERSION=21
DEFAULT_TARGET_SDK_VERSION=29
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-kustomer-sdk",
"title": "React Native Kustomer SDK",
"version": "2.0.1",
"version": "2.0.2",
"description": "Kustomer SDK for React Native",
"main": "index.js",
"files": [
Expand All @@ -27,6 +27,12 @@
"name": "Paula Pallarés Borràs",
"email": "[email protected]"
},
"contributors": [
{
"name" : "sejoDjoseon",
"email" : "[email protected]"
}
],
"license": "MIT",
"licenseFilename": "LICENSE",
"readmeFilename": "README.md",
Expand Down

0 comments on commit b48875c

Please sign in to comment.