Skip to content

Commit

Permalink
Feature/improve docs (#4)
Browse files Browse the repository at this point in the history
* Improved homepage Readme

* Added automatic publishing to gh-pages branch

* Added /docs/build to gitignore

* Fix baseUrl for documentation site

* Fix social github link from documentation site

* Smaller homepage subtitles

* Added project readme.

* Update baseUrl

* update build version
  • Loading branch information
sahataba authored Sep 18, 2020
1 parent c59dc40 commit 705bede
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/captures
.externalNativeBuild
.cxx
/docs/build
4 changes: 2 additions & 2 deletions cere_sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.01"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down
4 changes: 2 additions & 2 deletions cere_sdk/src/main/java/io/cere/cere_sdk/CereModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import android.webkit.JavascriptInterface
import android.webkit.WebView


const val baseUrl: String = "http://sdk-common.cere.io.s3-website-us-west-2.amazonaws.com/native.html"
const val baseUrl: String = "https://s3-us-west-2.amazonaws.com/sdk-common.cere.io/native.html"

/**
* Interface used after `CereModule` init method.
Expand Down Expand Up @@ -110,7 +110,7 @@ class CereModule(private val context: Context) {
private val version: String = context.packageManager.getPackageInfo(context.packageName, 0).versionName

/**
* @return current sdk initialisation status instance of {@code InitStatus}
* @return current sdk initialization status instance of {@code InitStatus}
*/
fun getInitStatus(): InitStatus {
return this.initStatus
Expand Down
3 changes: 2 additions & 1 deletion docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
orchidRuntime "io.github.javaeden.orchid:OrchidDocs:0.21.0"
orchidRuntime "io.github.javaeden.orchid:OrchidKotlindoc:0.21.0"
orchidRuntime "io.github.javaeden.orchid:OrchidPluginDocs:0.21.0"
orchidRuntime("io.github.javaeden.orchid:OrchidGithub:0.21.0")
}

// 3. Get dependencies from JCenter and Kotlinx Bintray repo
Expand All @@ -20,6 +21,6 @@ repositories {
// 4. Use the 'Editorial' theme, and set the URL it will have on Github Pages
orchid {
theme = "Editorial"
baseUrl = "https://username.github.io/project"
baseUrl = "https://cere-io.github.io/sdk-android"
version = "1.0.0"
}
11 changes: 9 additions & 2 deletions docs/src/orchid/resources/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Editorial:
primaryColor: '#DE9149'
legacySearch: false
social:
github: 'username/project'
github: 'cere-io/sdk-android'
metaComponents:
- type: 'orchidSearch'
menu:
Expand All @@ -28,4 +28,11 @@ Editorial:
moduleType: 'kotlindoc'
node: 'packages'
asSubmenu: true
submenuTitle: 'Packages'
submenuTitle: 'Packages'

services:
publications:
stages:
- type: 'githubPages'
username: 'sahataba' # todo: change it
repo: 'cere-io/sdk-android'
66 changes: 55 additions & 11 deletions docs/src/orchid/resources/homepage.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,72 @@
# Setup
## Setup

Minimal supported android SDK version is KITKAT.
```
minSdkVersion 19
```

Add jitpack repository to build.gradle file.
```
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```

Add kotlin library and cere_sdk library dependencies to your /app/build.gradle file.

```
dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
implementation files('/Users/sahataba/Workspace/sdk_android/cere_sdk/build/outputs/aar/cere_sdk-debug.aar')
implementation "com.github.cere-io:sdk-android:0.1"
}
```

# Initialisation
## Initialization

Import cere_sdk inside your MainActivity class.
Initialize CereModule inside your custom Application class, and call init method on CereModule with appId and integrationPartnerUserId.

```java
package io.cere.sdk_android_example;

import android.app.Application;
import android.util.Log;

import io.cere.cere_sdk.CereModule;
import io.cere.cere_sdk.InitStatus;

public class CustomApplication extends Application {
private static String TAG = "CustomApplication";
private CereModule cereModule = null;
public void onCreate() {
super.onCreate();
if (CereModule.getInstance(this).getInitStatus() == InitStatus.Initialised.INSTANCE) {
this.cereModule = CereModule.getInstance(this);
} else {
//you can handle other initialization statuses (Uninitialized, Initializing, InitializationError)
this.cereModule = CereModule.getInstance(this);
this.cereModule.setOnInitializationFinishedHandler(() -> {
this.cereModule.sendEvent("APP_LAUNCHED_TEST", "{'locationId': 10}");
return;
});
this.cereModule.setOnInitializationErrorHandler((String error) -> {
Log.e(TAG, error);
});
this.cereModule.init("242", "userID");
}
}
}
```

Call init method on CereModule with appId and externalUserId, inside MainActivity

todo: add links to javadoc from readme
Inside your MainActivity get an singleton instance of CereModule.

```java
package io.cere.sdk_android_example;

import androidx.appcompat.app.AppCompatActivity;
import io.cere.cere_sdk.CereModule;

public class MainActivity extends AppCompatActivity {

private CereModule cereModule;
Expand All @@ -35,18 +75,22 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.cereModule = CereModule.init(getApplicationContext(), "242", "userId");
}
this.cereModule = CereModule.getInstance(this.getApplication());
}
}
```

# Send events
## Send events

Anywhere from your app, call cereModule.sendEvent to trigger your event with custom payload.
Call cereModule.sendEvent to trigger your event with custom payload.

For quick integration test, you can use "APP_LAUNCHED_TEST" event, which will trigger display of "Hello world!" text inside android modal dialog.

```java
this.cereModule.sendEvent("APP_LAUNCHED_TEST", "{}");
```

## Example application

Take a look on [Example application](https://github.com/cere-io/sdk-android-example).

13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Building documentation
For building documentation we use [orchid](https://orchid.run/)
Using standard approach of publishing to gh-pages branch.

```
./gradlew :docs:orchidDeploy -PorchidEnvironment=prod
```

[Documentation site](https://cere-io.github.io/sdk-android/)

## Library publishing

See [dcendents](https://github.com/dcendents/android-maven-gradle-plugin)

0 comments on commit 705bede

Please sign in to comment.