Skip to content

Commit 9d599ae

Browse files
authored
Merge pull request #8 from snabble/feature/documentation
Documentation
2 parents abe8f21 + f35b378 commit 9d599ae

File tree

111 files changed

+1749
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1749
-113
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main, master ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main, master ]
88

99
jobs:
1010
build:
@@ -17,4 +17,4 @@ jobs:
1717
with:
1818
java-version: 12
1919
- name: Build
20-
run: ./gradlew build
20+
run: ./gradlew build

.github/workflows/publish.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ jobs:
2424
- name: Publish to GitHub Packages
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository
27+
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository
28+
- name: Generate documentation
29+
run: ./gradlew dokkaGfmMultiModule && sed -E 's/^## \[([^[]+)\]$/## \1/g' CHANGELOG.md | sed -E 's/^### (.+)$/**\1**\n/g' | sed -E 's/All notable changes to this project will be documented in this file./All notable changes of the Android SDK are noted in this document./' > docs/docs/changelog.md
30+
- name: Deploy documentation
31+
uses: mhausenblas/mkdocs-deploy-gh-pages@nomaterial
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
CONFIG_FILE: docs/mkdocs.yml
35+
REQUIREMENTS: docs/requirements.txt

build.gradle

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
buildscript {
2-
ext.kotlin_version = "1.5.31"
2+
ext.kotlin_version = '1.5.31'
33

44
repositories {
55
google()
66
mavenCentral()
7-
8-
maven {
9-
url "https://plugins.gradle.org/m2/"
10-
}
7+
maven { url 'https://plugins.gradle.org/m2/' }
118
}
129

1310
dependencies {
1411
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12+
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$kotlin_version"
13+
classpath "org.jetbrains.dokka:dokka-base:$kotlin_version"
1514
classpath 'com.android.tools.build:gradle:7.0.3'
1615
classpath 'gradle.plugin.com.github.jlouns:gradle-cross-platform-exec-plugin:0.5.0'
17-
classpath "gradle.plugin.gmazzo:sqlite-plugin:0.2"
16+
classpath 'gradle.plugin.gmazzo:sqlite-plugin:0.2'
1817
}
1918
}
2019

2120
plugins {
2221
id 'maven-publish'
22+
id 'org.jetbrains.dokka'
2323
}
2424

2525
allprojects {
2626
repositories {
2727
google()
2828
mavenCentral()
29-
maven { url "https://jitpack.io" }
30-
maven { url "https://datatrans.jfrog.io/artifactory/mobile-sdk/"}
29+
maven { url 'https://jitpack.io' }
30+
maven { url 'https://datatrans.jfrog.io/artifactory/mobile-sdk/'}
3131
}
3232

3333
project.ext {
@@ -42,37 +42,48 @@ allprojects {
4242
okhttpVersion='4.9.1'
4343
desugarVersion='1.1.5'
4444

45-
sdkVersion += project.getProperties().get("versionSuffix", "")
45+
sdkVersion += project.getProperties().get('versionSuffix', '')
4646
}
4747
}
4848

4949
afterEvaluate {
5050
publishing {
5151
repositories {
5252
maven {
53-
name = "LocalBuildDir"
54-
def releasesRepoUrl = "file://"+ project.rootDir.absolutePath +"/build/maven-releases/"
55-
def snapshotsRepoUrl = "file://"+ project.rootDir.absolutePath +"/build/maven-snapshots/"
53+
name = 'LocalBuildDir'
54+
def releasesRepoUrl = 'file://' + project.rootDir.absolutePath + '/build/maven-releases/'
55+
def snapshotsRepoUrl = 'file://' + project.rootDir.absolutePath + '/build/maven-snapshots/'
5656
url = rootProject.sdkVersion.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
5757
}
5858

5959
maven {
60-
name = "GitHubPackages"
61-
url = uri("https://maven.pkg.github.com/snabble/Android-SDK")
60+
name = 'GitHubPackages'
61+
url = uri('https://maven.pkg.github.com/snabble/Android-SDK')
6262

6363
credentials {
64-
username = System.getenv("GITHUB_ACTOR")
65-
password = System.getenv("GITHUB_TOKEN")
64+
username = System.getenv('GITHUB_ACTOR')
65+
password = System.getenv('GITHUB_TOKEN')
6666
}
6767
}
6868
}
6969
}
7070
}
7171

72+
tasks.named("dokkaHtml").configure {
73+
dokkaSourceSets {
74+
configureEach {
75+
skipDeprecated.set(true)
76+
}
77+
}
78+
}
79+
tasks.withType(org.jetbrains.dokka.gradle.AbstractDokkaTask).configureEach {
80+
outputDirectory.set(rootDir.toPath().resolve("docs/docs/api").toFile())
81+
}
82+
7283
task printVersion() {
7384
println project.sdkVersion
7485
}
7586

7687
task clean(type: Delete) {
7788
delete rootProject.buildDir
78-
}
89+
}

core/build.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
3-
apply from:'../scripts/maven.gradle'
4-
apply plugin: "org.jetbrains.kotlin.plugin.parcelize"
3+
apply from: '../scripts/maven.gradle'
4+
apply plugin: 'org.jetbrains.kotlin.plugin.parcelize'
5+
apply plugin: 'org.jetbrains.dokka'
56

67
android {
78
compileSdkVersion project.compileSdkVersion
@@ -12,11 +13,11 @@ android {
1213
targetSdkVersion project.targetSdkVersion
1314
versionCode project.versionCode
1415
versionName project.sdkVersion
15-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1617
consumerProguardFiles 'proguard-rules.pro'
1718

1819
// since AGP 4.1.0 this field is missing - WTF?
19-
buildConfigField "String", "VERSION_NAME", '"' + versionName + '"'
20+
buildConfigField 'String', 'VERSION_NAME', '"' + versionName + '"'
2021
}
2122

2223
buildTypes {
@@ -38,8 +39,8 @@ android {
3839
}
3940

4041
kotlinOptions {
41-
freeCompilerArgs = ["-Xjvm-default=all"]
42-
jvmTarget = "1.8"
42+
freeCompilerArgs = ['-Xjvm-default=all']
43+
jvmTarget = '1.8'
4344
}
4445

4546
testOptions {
@@ -54,12 +55,13 @@ dependencies {
5455

5556
implementation project(':utils')
5657

57-
implementation 'androidx.appcompat:appcompat:1.3.1'
58+
//noinspection GradleDependency
5859
implementation 'commons-io:commons-io:2.5'
5960
implementation 'org.apache.commons:commons-lang3:3.12.0'
6061
implementation 'org.iban4j:iban4j:3.2.1'
6162
implementation 'com.caverock:androidsvg-aar:1.4'
6263
implementation 'com.google.android.gms:play-services-wallet:18.1.3'
64+
implementation 'androidx.appcompat:appcompat:1.3.1'
6365
implementation 'androidx.biometric:biometric:1.2.0-alpha03'
6466

6567
api "com.squareup.okhttp3:okhttp:${project.okhttpVersion}"

core/src/test/java/io/snabble/sdk/GS1CodeTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class GS1CodeTest {
7070

7171
@Test
7272
fun testSingle() {
73-
// check("010000000000000", null, listOf("010000000000000"))
73+
check("010000000000000", null, listOf("010000000000000"))
7474
check("010000000000000_${GS}01123", null, listOf("010000000000000_", "01123"))
7575
}
7676

docs/docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
api
2+
changelog.md

docs/docs/android-api.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Installation
2+
3+
## Requirements
4+
5+
minSdkVersion = 21
6+
compileSdkVersion = 29
7+
java 8
8+
9+
androidx and a material components theme for ui components
10+
11+
### Using the snabble GitHub Repository
12+
13+
Add the snabble maven repository for out and the Datatrans SDK:
14+
15+
``` groovy
16+
repositories {
17+
maven {
18+
url 'https://raw.githubusercontent.com/snabble/maven-repository/releases'
19+
}
20+
}
21+
```
22+
23+
Then add the library to your dependencies.
24+
25+
``` groovy
26+
dependencies {
27+
// core library
28+
implementation 'io.snabble.sdk:core:{{ extra.sdk_version }}'
29+
30+
// user interface library
31+
implementation 'io.snabble.sdk:ui:{{ extra.sdk_version }}'
32+
33+
// user interface integration library, entirely optional,
34+
// for more seamless and easier integration in apps
35+
implementation 'io.snabble.sdk:ui-integration:{{ extra.sdk_version }}'
36+
}
37+
```
38+
39+
### Locally
40+
41+
The library can be installed to the local maven repository using:
42+
43+
``` sh
44+
./gradlew publishToMavenLocal
45+
```
46+
47+
Make sure you add maven local to your repositories in your gradle script.
48+
49+
``` groovy
50+
repositories {
51+
mavenLocal()
52+
}
53+
```
54+
55+
Then add the library to your dependencies. (Note: The + means it always uses the latest version)
56+
57+
``` groovy
58+
dependencies {
59+
implementation 'io.snabble.sdk:core:{{ extra.sdk_version }}'
60+
implementation 'io.snabble.sdk:ui:{{ extra.sdk_version }}'
61+
implementation 'io.snabble.sdk:ui-integration:{{ extra.sdk_version }}'
62+
}
63+
```
64+
65+
## Usage
66+
``` java
67+
//you may enable debug logging to see requests made by the sdk, and other various logs
68+
Snabble.setDebugLoggingEnabled(true);
69+
70+
Snabble.Config config = new Snabble.Config();
71+
config.appId = <your app id>
72+
config.secret = <your secret>
73+
74+
// optional: provide a metadata file, store in the assets. That allows the sdk
75+
// init without requiring a network connection.
76+
config.bundledMetadataAssetPath = "metadata.json";
77+
78+
final Snabble snabble = Snabble.getInstance();
79+
snabble.setup(this, config, new Snabble.SetupCompletionListener() {
80+
@Override
81+
public void onReady() {
82+
// get the first project, there can be multiple projects per app
83+
project = snabble.getProjects().get(0);
84+
85+
// registers this project globally for use with ui components
86+
SnabbleUI.useProject(project);
87+
88+
// select the first shop for demo purposes, ideally this should be done with
89+
// geofencing or a manual user selection
90+
if (project.getShops().length > 0) {
91+
project.getCheckout().setShop(project.getShops()[0]);
92+
}
93+
94+
// optional: set a loyalty card id for identification, for demo purposes
95+
// we invent one here
96+
project.setLoyaltyCardId("testAppUserLoyaltyCardId");
97+
98+
// optional: load a bundled database file from the assets folder
99+
// this lowers the download size of database updates and the database is immediatly
100+
// available offline
101+
project.getProductDatabase().loadDatabaseBundle("db.sqlite3", revision, major, minor);
102+
103+
// recommended: download the latest product database for offline availability
104+
// it is highly recommended to call this in shorter time frames than config.maxProductDatabaseAge is set at
105+
// since the local database is only used if the time since the last update is smaller than
106+
// config.maxProductDatabaseAge, which defaults to 1 hour
107+
//
108+
// a good place for this is the onStart() method of your activity
109+
// database updates are usually very small since we are using delta updates for updating the database
110+
//
111+
// also a good place for database updates are background schedulers like
112+
// https://developer.android.com/topic/libraries/architecture/workmanager
113+
project.getProductDatabase().update();
114+
}
115+
116+
@Override
117+
public void onError(Snabble.Error error) {
118+
// connecton error if no metadata file is bundled or config error
119+
// if no appId or secret is provided
120+
}
121+
});
122+
```

docs/docs/index.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Introduction
2+
Offer Scan & Go to your customers in your own app – with the Snabble Mobile SDK. Our mobile SDK supports the entire range of Snabble base functionality including scanning, product lists, promotions, payment and shops.
3+
The SDK covers the whole communication with the Snabble Cloud-Platform and provides you with UI elements for your app that are easy to use and customize, so that you simplify the integration of Scan & Go into your app significantly.
4+
For details about integrating with the Snabble Cloud-Platform, please see the [Platform Documentation](https://github.com/snabble/docs) on GitHub.
5+
6+
## Distribution & Download
7+
### iOS
8+
* [Snabble Mobile SDK for iOS on GitHub](https://github.com/snabble/iOS-SDK)
9+
* Supported iOS versions: iOS 12+
10+
11+
### Android
12+
* [Snabble Mobile SDK for Android on GitHub](https://github.com/snabble/Android-SDK)
13+
* [Sample Apps](sample-apps.md)
14+
* Supported Android versions: Android 8+
15+
16+
## Feature Overview
17+
### Scanning Products
18+
The SDK comes with a standard scanner functionality and the ability to match the scanned data to products, coupons or even deposits. The product data is provided through the SDK with great performance and includes all necessary product details also covering special cases like age verification, multiple taxation options or product related discounts and promotions.
19+
With this enriched product data and the provided SDK UI elements it is very simple to integrate a fully functional product scanner into your app.
20+
### Offline Synchronisation
21+
When entering a store with an app using the Snabble Mobile SDK, product data is downloaded into the app. This not only allows for a much faster scan result, but more importantly, it allows for scanning in areas of the store where no connection to the internet is available. After the purchase, product data is kept up-to-date via intelligent delta updates.
22+
### Cart
23+
The SDK comes with ready to use UI for the shopping cart that is already integrated into the scanner view. The cart handles not just adding and removing products but also synchronization with the Snabble Cloud-Platform. In this way the cart is automatically processed and updated by Snabble Cloud-Platform components like a promotion engine.
24+
In this way the cart always shows correct pricing information considering applicable coupons, manual discounts, bundles or similar promotion logic.
25+
The SDK UI elements for the cart already include visual representation of special cart items like 18+ products or applied promotions.
26+
### Promotions
27+
The Snabble Cloud-Platform already provides a powerful promotion engine to manage promotions. If you choose to use your own system to manage promotions this system will be integrated into the Snabble Cloud-Platform in advance. In all cases the SDK provides you with ready to use functionality for promotions.
28+
There are two main promotion functions provided through the SDK:
29+
manual discounts
30+
manual discounts that can be selected by the customer during the scanning process. The SDK UI elements for the product scanner contain elements for the selection of manual discounts if these are configured in the promotion engine.
31+
shopping cart calculation
32+
automated calculation and updates of the shopping cart using the promotion logic attached to the Snabble Cloud-Platform. The visual representation of applied promotions is already included in the SDK UI elements for the shopping cart.
33+
### Loyalty Cards
34+
Loyalty Cards can be added to the app by scanning or entering the information using the keyboard. Added loyalty cards are then automatically applied to each checkout.
35+
<!--
36+
### Empties And Deposits
37+
### Vending Machine Output
38+
### Checkout Options
39+
Lorem ipsum
40+
-->
41+
### Payment
42+
Using the Snabble Mobile SDK, your app is able to handle payments with the Payment Service Providers Fiserv (First Data, Telecash), PayOne and Datatrans. You choose which payment methods you want to offer to your customers. These payment methods are currently supported by our Snabble Mobile SDK:
43+
44+
#### Fiserv (First Data, Telecash)
45+
* SEPA Direct Debit
46+
* Credit Cards (VISA, MasterCard, American Express)
47+
* Apple Pay
48+
* Google Pay
49+
#### PayOne
50+
* SEPA Direct Debit
51+
* Credit Cards (VISA, MasterCard, American Express)
52+
#### Datatrans
53+
* Postfinance
54+
* Twint
55+
56+
### Offline Payment
57+
The Snabble Mobile SDK is also able to generate a QR code containing the cart information. This QR code can be scanned by your PoS/Cashdesk. Payment is then handled by your PoS.
58+
### Shop List And Details
59+
A list of available shops is downloaded from the Snabble Cloud-Platform and shown in a table list inside the app. If the user has allowed to use geolocation, the shops are sorted by distance to the user. Also, a detail view of each shop is available, including a map view.
60+

docs/docs/logo.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)