Skip to content

Commit ea8a20e

Browse files
committed
add support for digital coupons
1 parent 185f04d commit ea8a20e

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.44.0]
5+
6+
### Added
7+
- Added support for DIGITAL coupons with additional fields
8+
49
## [0.43.2]
510

611
### Added

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ allprojects {
3131
}
3232

3333
project.ext {
34-
sdkVersion='0.43.2'
34+
sdkVersion='0.44.0'
3535
versionCode=1
3636

3737
compileSdkVersion=30

core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33
apply from:'../scripts/maven.gradle'
4+
apply plugin: "org.jetbrains.kotlin.plugin.parcelize"
45

56
android {
67
compileSdkVersion project.compileSdkVersion

core/src/main/java/io/snabble/sdk/Coupons.kt

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
11
package io.snabble.sdk
22

3+
import android.os.Parcelable
34
import com.google.gson.annotations.SerializedName
5+
import kotlinx.parcelize.Parcelize
46

7+
@Parcelize
58
data class Coupon (
69
val id: String,
7-
val name: String,
10+
val name: String?,
11+
val description: String?,
12+
val promotionDescription: String?,
813
val type: CouponType,
9-
val codes: List<CouponCode>,
10-
)
14+
val codes: List<CouponCode>?,
15+
val code: String?,
16+
val validFrom: String?,
17+
val validUntil: String?,
18+
val image: CouponImage?
19+
) : Parcelable
1120

21+
@Parcelize
1222
data class CouponCode (
1323
val code: String,
1424
val template: String,
15-
)
25+
) : Parcelable
26+
27+
@Parcelize
28+
data class CouponImage (
29+
val name: String,
30+
val formats: List<CouponImageFormats>,
31+
) : Parcelable
32+
33+
@Parcelize
34+
data class CouponImageFormats (
35+
val contentType: String,
36+
val width: Int,
37+
val height: Int,
38+
val size: String,
39+
val url: String,
40+
) : Parcelable
1641

1742
enum class CouponType {
1843
@SerializedName("manual") MANUAL,
1944
@SerializedName("printed") PRINTED,
2045
@SerializedName("digital") DIGITAL,
2146
}
2247

23-
data class PersistedCouponData (
24-
val activatedCouponIds: MutableList<String> = mutableListOf(),
25-
val printedCouponsIds: MutableList<String> = mutableListOf(),
26-
)
27-
2848
class Coupons (
2949
private val coupons: List<Coupon>,
3050
) {

core/src/main/java/io/snabble/sdk/ShoppingCart.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ public void add(Item item) {
130130
insert(item, 0);
131131
}
132132

133+
/**
134+
* Adds coupons without adding a scanned code to it, you can use this function to quickly
135+
* add DIGITAL coupons that do not have a barcode associated with them
136+
*/
137+
public void addCoupon(Coupon coupon) {
138+
add(newItem(coupon, null));
139+
}
140+
141+
/**
142+
* Adds coupons with a scanned code to it, you can use this function to quickly
143+
* add PRINTED coupons
144+
*/
145+
public void addCoupon(Coupon coupon, ScannedCode scannedCode) {
146+
add(newItem(coupon, scannedCode));
147+
}
148+
133149
public void insert(Item item, int index) {
134150
insert(item, index, true);
135151
}

ui/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ dependencies {
6060
implementation 'me.relex:circleindicator:2.1.6'
6161
implementation 'ch.datatrans:android-sdk:1.4.1'
6262
implementation 'com.google.android.gms:play-services-wallet:18.1.3'
63+
implementation 'eu.rekisoft.android.util:LazyWorker:2.0.1'
6364

6465
def camerax_version = "1.0.0"
6566
implementation "androidx.camera:camera-core:${camerax_version}"
@@ -77,5 +78,4 @@ dependencies {
7778
testImplementation 'junit:junit:4.13.2'
7879
androidTestImplementation 'androidx.test:runner:1.3.0'
7980
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
80-
implementation 'eu.rekisoft.android.util:LazyWorker:2.0.0'
8181
}

ui/src/main/java/io/snabble/sdk/ui/utils/UIUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void onLayoutChange(View view, int left, int top, int right, int bottom,
128128

129129
Handler infoHandler = new Handler(Looper.getMainLooper());
130130
infoHandler.removeCallbacksAndMessages(null);
131-
LazyWorker.Job hide = LazyWorker.createLifeCycleAwareJob(parent.getContext(), () -> {
131+
LazyWorker.Job hide = LazyWorker.createLifeCycleAwareJob(parent.getContext(), (job) -> {
132132
if(info.isAttachedToWindow()) {
133133
info.animate()
134134
.translationY(-offsetY - info.getHeight())

0 commit comments

Comments
 (0)