diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c101cbe1df..20b1f07f86 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: "temurin" - java-version: 17 + java-version: 21 - name: Build run: ./gradlew build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0c83724d8e..63e77480e9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,11 +13,11 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: "temurin" - java-version: 17 + java-version: 21 - name: Build run: ./gradlew build - name: Publish to Maven Repository diff --git a/accessibility-toolbox/build.gradle.kts b/accessibility-toolbox/build.gradle.kts index 30843b00a6..8da11d89f6 100644 --- a/accessibility-toolbox/build.gradle.kts +++ b/accessibility-toolbox/build.gradle.kts @@ -1,17 +1,12 @@ -@file:Suppress("UnstableApiUsage") - import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id(libs.plugins.androidLibrary.get().pluginId) - id(libs.plugins.kotlin.android.get().pluginId) id(libs.plugins.dokka.get().pluginId) id(libs.plugins.kotlin.parcelize.get().pluginId) } -apply { - from("../scripts/maven.gradle") -} +apply(from = "../scripts/maven.gradle") description = "Accessibility-Toolbox: Make it easy to make your app accessible" @@ -40,21 +35,15 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - sourceSets { - getByName("main").java.srcDirs("src/main/kotlin") - getByName("test").java.srcDirs("src/test/kotlin") - getByName("androidTest").java.srcDirs("src/androidTest/kotlin") + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlin { compilerOptions { - jvmTarget = JvmTarget.JVM_17 + jvmTarget = JvmTarget.JVM_21 freeCompilerArgs.addAll( - "-Xjvm-default=all" + "-jvm-default=enable" ) } } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 1750a0a4e0..8322854819 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,17 +1,12 @@ -@file:Suppress("UnstableApiUsage") - import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id(libs.plugins.androidLibrary.get().pluginId) - id(libs.plugins.kotlin.android.get().pluginId) id(libs.plugins.dokka.get().pluginId) id(libs.plugins.kotlin.parcelize.get().pluginId) } -apply { - from("../scripts/maven.gradle") -} +apply(from = "../scripts/maven.gradle") description = "Snabble Core: The business logic of the Snabble SDK" @@ -44,15 +39,15 @@ android { compileOptions { isCoreLibraryDesugaringEnabled = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlin { compilerOptions { - jvmTarget = JvmTarget.JVM_17 + jvmTarget = JvmTarget.JVM_21 freeCompilerArgs.addAll( - "-Xjvm-default=all" + "-jvm-default=enable" ) } } diff --git a/core/proguard-rules.pro b/core/proguard-rules.pro index 4d0258ae95..72bd0067b9 100644 --- a/core/proguard-rules.pro +++ b/core/proguard-rules.pro @@ -1,28 +1,55 @@ --dontwarn java.lang.invoke.** +#-dontwarn java.lang.invoke.** +# +## OkHttp +#-keepattributes Signature +#-keepattributes *Annotation* +#-keep class okhttp3.** { *; } +#-keep interface okhttp3.** { *; } +#-dontwarn okhttp3.** +# +## Okio +#-keep class sun.misc.Unsafe { *; } +#-dontwarn java.nio.file.* +#-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement +#-dontwarn okio.** +# +## Picasso +#-dontwarn com.squareup.okhttp.** -# OkHttp +# Gson: keep any field annotated with @SerializedName so R8 cannot rename or remove it. +# This is the single rule that makes all @SerializedName annotations work under R8 strict mode. +-keepclassmembers,allowobfuscation class * { + @com.google.gson.annotations.SerializedName ; +} + +# Gson needs generic type signatures to deserialize parameterized types (e.g. List). -keepattributes Signature -keepattributes *Annotation* --keep class okhttp3.** { *; } --keep interface okhttp3.** { *; } --dontwarn okhttp3.** -# Okio --keep class sun.misc.Unsafe { *; } --dontwarn java.nio.file.* --dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement --dontwarn okio.** +# Retain TypeToken so Gson can resolve generic types at runtime. +-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken +-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken -# Picasso --dontwarn com.squareup.okhttp.** +# SDK +# Keep enum values()/valueOf() for Gson @SerializedName resolution. +# Keep public static final fields so .name() returns the declared constant name, +# not the obfuscated one — required for resource lookup in SnabbleInitializer. +-keepclassmembers enum io.snabble.sdk.** { + public static **[] values(); + public static ** valueOf(java.lang.String); + public static final ** *; +} -# Gson --keepattributes Signature --keepattributes *Annotation* --dontwarn sun.misc.** --keep class * implements com.google.gson.TypeAdapterFactory --keep class * implements com.google.gson.JsonSerializer --keep class * implements com.google.gson.JsonDeserializer +# Keep Parcelable CREATOR — required for cross-process parcel reconstruction +-keep class io.snabble.sdk.** implements android.os.Parcelable { + public static final ** CREATOR; +} -# SDK --keep class io.snabble.sdk.** { *; } +# Keep Serializable lifecycle methods +-keepclassmembers class io.snabble.sdk.** implements java.io.Serializable { + static final long serialVersionUID; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} diff --git a/core/src/main/java/io/snabble/sdk/Assets.java b/core/src/main/java/io/snabble/sdk/Assets.java index 4b52436973..b3f8e406b2 100644 --- a/core/src/main/java/io/snabble/sdk/Assets.java +++ b/core/src/main/java/io/snabble/sdk/Assets.java @@ -95,17 +95,17 @@ public enum Type { } private class ApiAsset { - String name; - Map variants; + @SerializedName("name") String name; + @SerializedName("variants") Map variants; } private class ApiManifest { - ApiAsset[] files; + @SerializedName("files") ApiAsset[] files; } private class Asset { - public String filePath; - public String hash; + @SerializedName("filePath") public String filePath; + @SerializedName("hash") public String hash; public Asset(String filePath, String hash) { this.filePath = filePath; @@ -114,7 +114,7 @@ public Asset(String filePath, String hash) { } private class Manifest { - Map assets; + @SerializedName("assets") Map assets; } private interface DownloadCallback { diff --git a/core/src/main/java/io/snabble/sdk/Brand.kt b/core/src/main/java/io/snabble/sdk/Brand.kt index 5ca629d6cf..83c274a4d7 100644 --- a/core/src/main/java/io/snabble/sdk/Brand.kt +++ b/core/src/main/java/io/snabble/sdk/Brand.kt @@ -1,10 +1,12 @@ package io.snabble.sdk +import com.google.gson.annotations.SerializedName + data class Brand( - val id: String, - val name: String, + @SerializedName("id") val id: String, + @SerializedName("name") val name: String, ) : Comparable { override fun compareTo(other: Brand) = compareValuesBy(this, other, { it.id }, ) -} \ No newline at end of file +} diff --git a/core/src/main/java/io/snabble/sdk/Company.kt b/core/src/main/java/io/snabble/sdk/Company.kt index cea8fb6af6..1a727e35f5 100644 --- a/core/src/main/java/io/snabble/sdk/Company.kt +++ b/core/src/main/java/io/snabble/sdk/Company.kt @@ -1,32 +1,19 @@ package io.snabble.sdk +import com.google.gson.annotations.SerializedName + /** * Class describing a company */ data class Company( - /** - * Get the name of the city - */ - @JvmField - val city: String?, - /** - * Get the name of the country - */ - @JvmField - val country: String?, - /** - * Get the companies name - */ - @JvmField - val name: String?, - /** - * Get the name of the street, including the house number - */ - @JvmField - val street: String?, - /** - * Get the zip code - */ - @JvmField - val zip: String? -) \ No newline at end of file + /** Get the name of the city */ + @JvmField @SerializedName("city") val city: String?, + /** Get the name of the country */ + @JvmField @SerializedName("country") val country: String?, + /** Get the companies name */ + @JvmField @SerializedName("name") val name: String?, + /** Get the name of the street, including the house number */ + @JvmField @SerializedName("street") val street: String?, + /** Get the zip code */ + @JvmField @SerializedName("zip") val zip: String? +) diff --git a/core/src/main/java/io/snabble/sdk/Config.kt b/core/src/main/java/io/snabble/sdk/Config.kt index 10f4c43643..bcf49c0254 100644 --- a/core/src/main/java/io/snabble/sdk/Config.kt +++ b/core/src/main/java/io/snabble/sdk/Config.kt @@ -1,6 +1,7 @@ package io.snabble.sdk import android.content.Context +import androidx.annotation.Keep import com.google.gson.JsonDeserializationContext import com.google.gson.JsonDeserializer import com.google.gson.JsonElement @@ -19,6 +20,7 @@ import java.util.concurrent.TimeUnit /** * Configuration of the snabble SDK. */ +@Keep data class Config ( /** * The endpoint url of the snabble backend. For example "https://api.snabble.io" for the Production environment. diff --git a/core/src/main/java/io/snabble/sdk/Environment.kt b/core/src/main/java/io/snabble/sdk/Environment.kt index bbadf38d19..c0fece88a2 100644 --- a/core/src/main/java/io/snabble/sdk/Environment.kt +++ b/core/src/main/java/io/snabble/sdk/Environment.kt @@ -1,9 +1,13 @@ package io.snabble.sdk +import androidx.annotation.Keep + /** * Enum describing the environment the app is using */ +@Keep enum class Environment(val domain: String) { + TESTING("snabble-testing.io"), STAGING("snabble-staging.io"), PRODUCTION("snabble.io"); @@ -19,6 +23,7 @@ enum class Environment(val domain: String) { val wildcardUrl: String = "*.$domain" companion object { + /** * Determine the environment by a url string */ diff --git a/core/src/main/java/io/snabble/sdk/MutableAccessibleLiveData.kt b/core/src/main/java/io/snabble/sdk/MutableAccessibleLiveData.kt index 43a36637aa..37ee84e08b 100644 --- a/core/src/main/java/io/snabble/sdk/MutableAccessibleLiveData.kt +++ b/core/src/main/java/io/snabble/sdk/MutableAccessibleLiveData.kt @@ -1,5 +1,7 @@ package io.snabble.sdk +import androidx.annotation.Keep + /** * Mutable LiveData with the current (possible not yet published) value. You * can observe changes like with regular MutableLiveData, just not inherited. @@ -12,6 +14,7 @@ package io.snabble.sdk * You can directly compare the value with the LiveData's value directly as * syntactic sugar. */ +@Keep class MutableAccessibleLiveData: AccessibleLiveData { constructor() : super() constructor(initialValue: T) : super(initialValue) @@ -26,4 +29,4 @@ class MutableAccessibleLiveData: AccessibleLiveData { public override fun setValue(value: T) { this.value = value } -} \ No newline at end of file +} diff --git a/core/src/main/java/io/snabble/sdk/PaymentMethod.kt b/core/src/main/java/io/snabble/sdk/PaymentMethod.kt index 8b0e465805..f639000fdf 100644 --- a/core/src/main/java/io/snabble/sdk/PaymentMethod.kt +++ b/core/src/main/java/io/snabble/sdk/PaymentMethod.kt @@ -201,13 +201,13 @@ enum class PaymentMethod( fun fromIdAndOrigin(id: String, origin: List): PaymentMethod? { entries.forEach { pm -> if (pm.id == id && pm.id == TEGUT_EMPLOYEE_CARD.id) { - when (origin[0]) { - "tegutEmployeeID" -> return TEGUT_EMPLOYEE_CARD - "contactPersonCredentials" -> return EXTERNAL_BILLING + return when (origin.firstOrNull()) { + "tegutEmployeeID" -> TEGUT_EMPLOYEE_CARD + "contactPersonCredentials" -> EXTERNAL_BILLING + else -> null } } else if (pm.id == id && pm.id == PAYONE_SEPA.id) { - //needed for deserialization - return when (origin[0]) { + return when (origin.firstOrNull()) { "payoneSepaData" -> PAYONE_SEPA else -> DE_DIRECT_DEBIT } diff --git a/core/src/main/java/io/snabble/sdk/PaymentMethodDescriptor.kt b/core/src/main/java/io/snabble/sdk/PaymentMethodDescriptor.kt index 4d34498692..f02694e1e1 100644 --- a/core/src/main/java/io/snabble/sdk/PaymentMethodDescriptor.kt +++ b/core/src/main/java/io/snabble/sdk/PaymentMethodDescriptor.kt @@ -1,5 +1,7 @@ package io.snabble.sdk +import com.google.gson.annotations.SerializedName + /** * A class describing a payment method */ @@ -7,20 +9,20 @@ data class PaymentMethodDescriptor( /** * Unique identifier of the payment method */ - val id: String, + @SerializedName("id") val id: String, /** * Various links for getting web forms or approval links */ - val links: Map?, + @SerializedName("links") val links: Map?, /** * The name of the underlying payment provider (e.g. telecash, payOne, googlePay) */ - val providerName: String, + @SerializedName("providerName") val providerName: String, /** * List of origin types that are accepted for this payment method (to match with locally saved * payment credentials) */ - val acceptedOriginTypes: List? + @SerializedName("acceptedOriginTypes") val acceptedOriginTypes: List? ) { /** @@ -35,5 +37,5 @@ data class PaymentMethodDescriptor( * Data class for a link */ data class Link( - val href: String + @SerializedName("href") val href: String ) diff --git a/core/src/main/java/io/snabble/sdk/Product.java b/core/src/main/java/io/snabble/sdk/Product.java index 83837af495..342b1f54fe 100644 --- a/core/src/main/java/io/snabble/sdk/Product.java +++ b/core/src/main/java/io/snabble/sdk/Product.java @@ -3,6 +3,7 @@ import android.os.Parcel; import android.os.Parcelable; +import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -23,6 +24,7 @@ /** * Class that holds all of the product information. */ +@Keep public class Product implements Serializable, Parcelable { public enum Type { /** diff --git a/core/src/main/java/io/snabble/sdk/ProductApi.java b/core/src/main/java/io/snabble/sdk/ProductApi.java index e1ae758f5c..96202fe36d 100644 --- a/core/src/main/java/io/snabble/sdk/ProductApi.java +++ b/core/src/main/java/io/snabble/sdk/ProductApi.java @@ -1,5 +1,7 @@ package io.snabble.sdk; +import androidx.annotation.Keep; + import com.google.gson.annotations.SerializedName; import io.snabble.sdk.codes.ScannedCode; @@ -13,26 +15,27 @@ /** * Class for interfacing with the snabble product API */ +@Keep class ProductApi { private static class ApiProduct { - String sku; - ApiProductType productType; - String name; - String description; - String subtitle; - String referenceUnit; - String encodingUnit; - String imageUrl; - String scanMessage; - ApiPrice price; - boolean saleStop; - boolean notForSale; - ApiScannableCode[] codes; - Product.SaleRestriction saleRestriction = Product.SaleRestriction.NONE; - ApiAvailability availability; - - ApiProduct deposit; - ApiProduct[] bundles; + @SerializedName("sku") String sku; + @SerializedName("productType") ApiProductType productType; + @SerializedName("name") String name; + @SerializedName("description") String description; + @SerializedName("subtitle") String subtitle; + @SerializedName("referenceUnit") String referenceUnit; + @SerializedName("encodingUnit") String encodingUnit; + @SerializedName("imageUrl") String imageUrl; + @SerializedName("scanMessage") String scanMessage; + @SerializedName("price") ApiPrice price; + @SerializedName("saleStop") boolean saleStop; + @SerializedName("notForSale") boolean notForSale; + @SerializedName("codes") ApiScannableCode[] codes; + @SerializedName("saleRestriction") Product.SaleRestriction saleRestriction = Product.SaleRestriction.NONE; + @SerializedName("availability") ApiAvailability availability; + + @SerializedName("deposit") ApiProduct deposit; + @SerializedName("bundles") ApiProduct[] bundles; } private enum ApiAvailability { @@ -45,10 +48,10 @@ private enum ApiAvailability { } private static class ApiPrice { - int listPrice; - int discountedPrice; - int customerCardPrice; - String basePrice; + @SerializedName("listPrice") int listPrice; + @SerializedName("discountedPrice") int discountedPrice; + @SerializedName("customerCardPrice") int customerCardPrice; + @SerializedName("basePrice") String basePrice; } private enum ApiProductType { @@ -61,13 +64,13 @@ private enum ApiProductType { } private static class ApiScannableCode { - String code; - String template; - String transmissionCode; - String transmissionTemplate; - String encodingUnit; - boolean isPrimary; - int specifiedQuantity; + @SerializedName("code") String code; + @SerializedName("template") String template; + @SerializedName("transmissionCode") String transmissionCode; + @SerializedName("transmissionTemplate") String transmissionTemplate; + @SerializedName("encodingUnit") String encodingUnit; + @SerializedName("isPrimary") boolean isPrimary; + @SerializedName("specifiedQuantity") int specifiedQuantity; } private final Project project; diff --git a/core/src/main/java/io/snabble/sdk/Project.kt b/core/src/main/java/io/snabble/sdk/Project.kt index bdfa35d6b0..3cbb332749 100644 --- a/core/src/main/java/io/snabble/sdk/Project.kt +++ b/core/src/main/java/io/snabble/sdk/Project.kt @@ -359,9 +359,6 @@ class Project internal constructor( lateinit var assets: Assets private set - lateinit var assetService: AssetService - private set - var appTheme: AppTheme? = null private set @@ -572,8 +569,6 @@ class Project internal constructor( assets = Assets(this) - assetService = assetServiceFactory(project = this, context = Snabble.application) - googlePayHelper = paymentMethodDescriptors .mapNotNull { it.paymentMethod } .firstOrNull { it == PaymentMethod.GOOGLE_PAY } diff --git a/core/src/main/java/io/snabble/sdk/ReceiptsApi.java b/core/src/main/java/io/snabble/sdk/ReceiptsApi.java index 08610b69b4..3c4264b053 100644 --- a/core/src/main/java/io/snabble/sdk/ReceiptsApi.java +++ b/core/src/main/java/io/snabble/sdk/ReceiptsApi.java @@ -25,25 +25,24 @@ public class ReceiptsApi { /** Data class for api receipts **/ public static class ApiReceipt { - public ApiOrder[] orders; + @SerializedName("orders") public ApiOrder[] orders; } /** Data class for api orders **/ public static class ApiOrder { - public String id; - public String project; - public String date; - @SerializedName("shopID") - public String shopId; - public String shopName; - public int price; - public Map links; - public boolean isSuccessful; + @SerializedName("id") public String id; + @SerializedName("project") public String project; + @SerializedName("date") public String date; + @SerializedName("shopID") public String shopId; + @SerializedName("shopName") public String shopName; + @SerializedName("price") public int price; + @SerializedName("links") public Map links; + @SerializedName("isSuccessful") public boolean isSuccessful; } /** Data class for api links **/ public static class ApiLink { - public String href; + @SerializedName("href") public String href; } /** diff --git a/core/src/main/java/io/snabble/sdk/Shop.java b/core/src/main/java/io/snabble/sdk/Shop.java index ad144bea26..4dc677ece5 100644 --- a/core/src/main/java/io/snabble/sdk/Shop.java +++ b/core/src/main/java/io/snabble/sdk/Shop.java @@ -49,7 +49,7 @@ public enum Service { * Class describing a link */ public static class Href { - private final String href; + @SerializedName("href") private final String href; public Href(String href) { this.href = href; @@ -75,9 +75,9 @@ public String toString() { * Class describing when a shop opens and closes */ public static class OpeningHourSpecification { - private final String closes; - private final String opens; - private final String dayOfWeek; + @SerializedName("closes") private final String closes; + @SerializedName("opens") private final String opens; + @SerializedName("dayOfWeek") private final String dayOfWeek; OpeningHourSpecification(String closes, String opens, String dayOfWeek) { this.closes = closes; @@ -121,7 +121,7 @@ public String toString() { * Class describing a potentially available wifi network in the shop */ public static class CustomerNetwork { - private final String ssid; + @SerializedName("ssid") private final String ssid; CustomerNetwork(String ssid) { this.ssid = ssid; @@ -142,29 +142,25 @@ public String toString() { } } - private String id; - private String externalId; - private String name; - private Service[] services; - private String street; - @SerializedName("zip") - private String zipCode; - private String city; - private String country; - private String state; - private String phone; - private String email; - private boolean isPreLaunch; - private Map links; - @SerializedName("lat") - private double latitude; - @SerializedName("lon") - private double longitude; - private CustomerNetwork[] customerNetworks; - private OpeningHourSpecification[] openingHoursSpecification; - private JsonElement external; - @SerializedName("shopServices") - private ShopServices[] shopServices; + @SerializedName("id") private String id; + @SerializedName("externalId") private String externalId; + @SerializedName("name") private String name; + @SerializedName("services") private Service[] services; + @SerializedName("street") private String street; + @SerializedName("zip") private String zipCode; + @SerializedName("city") private String city; + @SerializedName("country") private String country; + @SerializedName("state") private String state; + @SerializedName("phone") private String phone; + @SerializedName("email") private String email; + @SerializedName("isPreLaunch") private boolean isPreLaunch; + @SerializedName("links") private Map links; + @SerializedName("lat") private double latitude; + @SerializedName("lon") private double longitude; + @SerializedName("customerNetworks") private CustomerNetwork[] customerNetworks; + @SerializedName("openingHoursSpecification") private OpeningHourSpecification[] openingHoursSpecification; + @SerializedName("external") private JsonElement external; + @SerializedName("shopServices") private ShopServices[] shopServices; Shop() { // for gson diff --git a/core/src/main/java/io/snabble/sdk/SnabbleInitializer.kt b/core/src/main/java/io/snabble/sdk/SnabbleInitializer.kt index d39065e59a..986580e65e 100644 --- a/core/src/main/java/io/snabble/sdk/SnabbleInitializer.kt +++ b/core/src/main/java/io/snabble/sdk/SnabbleInitializer.kt @@ -88,8 +88,8 @@ class SnabbleInitializer : Initializer { networkInterceptor = try { Class.forName(getString("snabble_network_interceptor", null)) - ?.getDeclaredConstructor() - ?.newInstance() as Interceptor? + .getDeclaredConstructor() + .newInstance() as Interceptor? } catch (e: Throwable) { Logger.w("Could not instantiate network interceptor", e.message) null diff --git a/core/src/main/java/io/snabble/sdk/TermsOfService.kt b/core/src/main/java/io/snabble/sdk/TermsOfService.kt index 71537e8c84..e924e923d1 100644 --- a/core/src/main/java/io/snabble/sdk/TermsOfService.kt +++ b/core/src/main/java/io/snabble/sdk/TermsOfService.kt @@ -1,14 +1,15 @@ package io.snabble.sdk +import com.google.gson.annotations.SerializedName import java.util.* /** * Class for describing our terms of service. */ data class TermsOfService( - val updatedAt: String, - val version: String, - val variants: List = emptyList() + @SerializedName("updatedAt") val updatedAt: String, + @SerializedName("version") val version: String, + @SerializedName("variants") val variants: List = emptyList() ) { /** * Gets a link to a downloadable html in the current system language or a default if no @@ -34,45 +35,24 @@ data class TermsOfService( } else null } - /** - * A variant of the terms of service document - */ + /** A variant of the terms of service document */ data class Variant( - /** - * True if this is the default terms of service to display if - * a language specific one is not available - */ - val isDefault: Boolean = false, - /** - * The iso2 language of the document - */ - val language: String, - /** - * Link to the html document - */ - val links: Links + @SerializedName("isDefault") val isDefault: Boolean = false, + @SerializedName("language") val language: String, + @SerializedName("links") val links: Links ) { - /** - * The relative url of the html document - */ + /** The relative url of the html document */ val url: String get() = links.content.href } - /** - * Class for link encapsulation - */ + /** Class for link encapsulation */ data class Links( - val content: Content + @SerializedName("content") val content: Content ) - /** - * Class for link encapsulation - */ + /** Class for link encapsulation */ data class Content( - /** - * The relative url of the html document - */ - val href: String + @SerializedName("href") val href: String ) } diff --git a/core/src/main/java/io/snabble/sdk/ViolationNotification.kt b/core/src/main/java/io/snabble/sdk/ViolationNotification.kt index 1666de1740..fb56515bb5 100644 --- a/core/src/main/java/io/snabble/sdk/ViolationNotification.kt +++ b/core/src/main/java/io/snabble/sdk/ViolationNotification.kt @@ -1,10 +1,12 @@ package io.snabble.sdk +import androidx.annotation.Keep import io.snabble.sdk.checkout.ViolationType /** * A notification that a violation occurred */ +@Keep data class ViolationNotification( /** The name of the affected violation item, e.g. a coupon **/ val name: String?, diff --git a/core/src/main/java/io/snabble/sdk/auth/AppUser.java b/core/src/main/java/io/snabble/sdk/auth/AppUser.java index bff15d652a..22caed7a18 100644 --- a/core/src/main/java/io/snabble/sdk/auth/AppUser.java +++ b/core/src/main/java/io/snabble/sdk/auth/AppUser.java @@ -1,10 +1,11 @@ package io.snabble.sdk.auth; +import com.google.gson.annotations.SerializedName; import java.util.Objects; public class AppUser { - public final String id; - public final String secret; + @SerializedName("id") public final String id; + @SerializedName("secret") public final String secret; public AppUser(String id, String secret) { this.id = id; diff --git a/core/src/main/java/io/snabble/sdk/auth/AppUserAndToken.java b/core/src/main/java/io/snabble/sdk/auth/AppUserAndToken.java index 2ec7476495..5208650a7a 100644 --- a/core/src/main/java/io/snabble/sdk/auth/AppUserAndToken.java +++ b/core/src/main/java/io/snabble/sdk/auth/AppUserAndToken.java @@ -1,8 +1,10 @@ package io.snabble.sdk.auth; +import com.google.gson.annotations.SerializedName; + public class AppUserAndToken { - public final Token token; - public final AppUser appUser; + @SerializedName("token") public final Token token; + @SerializedName("appUser") public final AppUser appUser; public AppUserAndToken(Token token, AppUser appUser) { this.token = token; diff --git a/core/src/main/java/io/snabble/sdk/auth/Token.java b/core/src/main/java/io/snabble/sdk/auth/Token.java index 16ccd06b65..6eb7ff663f 100644 --- a/core/src/main/java/io/snabble/sdk/auth/Token.java +++ b/core/src/main/java/io/snabble/sdk/auth/Token.java @@ -1,10 +1,12 @@ package io.snabble.sdk.auth; +import com.google.gson.annotations.SerializedName; + public class Token { - public final String id; - public final String token; - public final long issuedAt; - public final long expiresAt; + @SerializedName("id") public final String id; + @SerializedName("token") public final String token; + @SerializedName("issuedAt") public final long issuedAt; + @SerializedName("expiresAt") public final long expiresAt; public Token(String id, String token, long issuedAt, long expiresAt) { this.id = id; diff --git a/core/src/main/java/io/snabble/sdk/checkout/CheckoutApi.kt b/core/src/main/java/io/snabble/sdk/checkout/CheckoutApi.kt index d2462491d6..6e4dce23fd 100644 --- a/core/src/main/java/io/snabble/sdk/checkout/CheckoutApi.kt +++ b/core/src/main/java/io/snabble/sdk/checkout/CheckoutApi.kt @@ -144,13 +144,13 @@ enum class RoutingTarget { } data class Href( - val href: String? = null, + @SerializedName("href") val href: String? = null, ) : Serializable data class SignedCheckoutInfo( - val checkoutInfo: JsonObject? = null, - val signature: String? = null, - val links: Map? = null, + @SerializedName("checkoutInfo") val checkoutInfo: JsonObject? = null, + @SerializedName("signature") val signature: String? = null, + @SerializedName("links") val links: Map? = null, ) { val checkoutProcessLink: String? get() = links?.get("checkoutProcess")?.href @@ -209,15 +209,15 @@ data class SignedCheckoutInfo( } data class CheckoutInfo( - val price: Price? = null, - val lineItems: List = emptyList(), - val violations: List = emptyList(), + @SerializedName("price") val price: Price? = null, + @SerializedName("lineItems") val lineItems: List = emptyList(), + @SerializedName("violations") val violations: List = emptyList(), ) data class Violation( - val type: ViolationType? = null, - val refersTo: String? = null, - val message: String? = null, + @SerializedName("type") val type: ViolationType? = null, + @SerializedName("refersTo") val refersTo: String? = null, + @SerializedName("message") val message: String? = null, ) enum class ViolationType { @@ -238,103 +238,102 @@ enum class ViolationType { } data class LineItem( - val id: String? = null, - val amount: Int = 0, - @SerializedName("couponID") - val couponId: String? = null, - val discountID: String? = null, - val discountRuleID: String? = null, - val discountType: String? = null, - val listPrice: Int = 0, - val name: String? = null, - val price: Int = 0, - val priceModifiers: List? = null, - val redeemed: Boolean = false, - val refersTo: String? = null, - val referenceUnit: String? = null, - val scannedCode: String? = null, - val sku: String? = null, - val totalPrice: Int = 0, - val type: LineItemType? = null, - val units: Int? = null, - val weight: Int? = null, - val weightUnit: String? = null, + @SerializedName("id") val id: String? = null, + @SerializedName("amount") val amount: Int = 0, + @SerializedName("couponID") val couponId: String? = null, + @SerializedName("discountID") val discountID: String? = null, + @SerializedName("discountRuleID") val discountRuleID: String? = null, + @SerializedName("discountType") val discountType: String? = null, + @SerializedName("listPrice") val listPrice: Int = 0, + @SerializedName("name") val name: String? = null, + @SerializedName("price") val price: Int = 0, + @SerializedName("priceModifiers") val priceModifiers: List? = null, + @SerializedName("redeemed") val redeemed: Boolean = false, + @SerializedName("refersTo") val refersTo: String? = null, + @SerializedName("referenceUnit") val referenceUnit: String? = null, + @SerializedName("scannedCode") val scannedCode: String? = null, + @SerializedName("sku") val sku: String? = null, + @SerializedName("totalPrice") val totalPrice: Int = 0, + @SerializedName("type") val type: LineItemType? = null, + @SerializedName("units") val units: Int? = null, + @SerializedName("weight") val weight: Int? = null, + @SerializedName("weightUnit") val weightUnit: String? = null, ) data class PriceModifier( - val name: String? = null, - val price: Int = 0, - val action: String? = null + @SerializedName("name") val name: String? = null, + @SerializedName("price") val price: Int = 0, + @SerializedName("action") val action: String? = null ) data class ExitToken( - val value: String? = null, - val format: String? = null, + @SerializedName("value") val value: String? = null, + @SerializedName("format") val format: String? = null, ) data class Price( - val price: Int = 0, - val netPrice: Int = 0, + @SerializedName("price") val price: Int = 0, + @SerializedName("netPrice") val netPrice: Int = 0, ) data class PaymentInformation( - val qrCodeContent: String? = null, - val encryptedOrigin: String? = null, - val originType: String? = null, - val validUntil: String? = null, - val cardNumber: String? = null, - val deviceID: String? = null, - val deviceName: String? = null, - val deviceFingerprint: String? = null, - val deviceIPAddress: String? = null, - val handoverInformation: String? = null, - val subject: String? = null + @SerializedName("qrCodeContent") val qrCodeContent: String? = null, + @SerializedName("encryptedOrigin") val encryptedOrigin: String? = null, + @SerializedName("originType") val originType: String? = null, + @SerializedName("validUntil") val validUntil: String? = null, + @SerializedName("cardNumber") val cardNumber: String? = null, + @SerializedName("deviceID") val deviceID: String? = null, + @SerializedName("deviceName") val deviceName: String? = null, + @SerializedName("deviceFingerprint") val deviceFingerprint: String? = null, + @SerializedName("deviceIPAddress") val deviceIPAddress: String? = null, + @SerializedName("handoverInformation") val handoverInformation: String? = null, + @SerializedName("subject") val subject: String? = null ) data class CheckoutProcessRequest( - val signedCheckoutInfo: SignedCheckoutInfo? = null, - val paymentMethod: PaymentMethod? = null, - val paymentInformation: PaymentInformation? = null, - val finalizedAt: String? = null, - val processedOffline: Boolean? = null, + @SerializedName("signedCheckoutInfo") val signedCheckoutInfo: SignedCheckoutInfo? = null, + @SerializedName("paymentMethod") val paymentMethod: PaymentMethod? = null, + @SerializedName("paymentInformation") val paymentInformation: PaymentInformation? = null, + @SerializedName("finalizedAt") val finalizedAt: String? = null, + @SerializedName("processedOffline") val processedOffline: Boolean? = null, ) data class PaymentMethodInfo( - val id: String? = null, - val isTesting: Boolean = false, - val acceptedOriginTypes: List = emptyList() + @SerializedName("id") val id: String? = null, + @SerializedName("isTesting") val isTesting: Boolean = false, + @SerializedName("acceptedOriginTypes") val acceptedOriginTypes: List = emptyList() ) data class PaymentResult( - val originCandidateLink: String? = null, - val failureCause: String? = null, + @SerializedName("originCandidateLink") val originCandidateLink: String? = null, + @SerializedName("failureCause") val failureCause: String? = null, ) data class AuthorizePaymentRequest( - val encryptedOrigin: String? = null, - val name: String? = null, - val countryCode: String? = null, - val state: String? = null + @SerializedName("encryptedOrigin") val encryptedOrigin: String? = null, + @SerializedName("name") val name: String? = null, + @SerializedName("countryCode") val countryCode: String? = null, + @SerializedName("state") val state: String? = null ) data class Check( - val id: String? = null, - val links: Map? = null, - val type: CheckType? = null, - val requiredAge: Int? = null, - val performedBy: Performer? = null, - val state: CheckState? = null, + @SerializedName("id") val id: String? = null, + @SerializedName("links") val links: Map? = null, + @SerializedName("type") val type: CheckType? = null, + @SerializedName("requiredAge") val requiredAge: Int? = null, + @SerializedName("performedBy") val performedBy: Performer? = null, + @SerializedName("state") val state: CheckState? = null, ) { val selfLink: String? get() = links?.get("self")?.href } data class Fulfillment( - val id: String? = null, - val type: String? = null, - val state: FulfillmentState? = null, - val refersTo: List = emptyList(), - val links: Map? = null, + @SerializedName("id") val id: String? = null, + @SerializedName("type") val type: String? = null, + @SerializedName("state") val state: FulfillmentState? = null, + @SerializedName("refersTo") val refersTo: List = emptyList(), + @SerializedName("links") val links: Map? = null, ) { val selfLink: String? get() = links?.get("self")?.href @@ -365,22 +364,20 @@ enum class DepositReturnVoucherState { } data class CheckoutProcessResponse( - val links: Map? = null, - val checks: List = emptyList(), - @SerializedName("orderID") - val orderId: String? = null, - @SerializedName("depositReturnVouchers") - val depositReturnVouchers: List? = null, - val aborted: Boolean = false, - val paymentMethod: PaymentMethod? = null, - val paymentInformation: PaymentInformation? = null, - val paymentPreauthInformation: JsonObject? = null, - val exitToken: ExitToken? = null, - val paymentState: CheckState? = null, - val pricing: Pricing? = null, - val routingTarget: RoutingTarget? = null, - val paymentResult: PaymentResult? = null, - val fulfillments: List = emptyList(), + @SerializedName("links") val links: Map? = null, + @SerializedName("checks") val checks: List = emptyList(), + @SerializedName("orderID") val orderId: String? = null, + @SerializedName("depositReturnVouchers") val depositReturnVouchers: List? = null, + @SerializedName("aborted") val aborted: Boolean = false, + @SerializedName("paymentMethod") val paymentMethod: PaymentMethod? = null, + @SerializedName("paymentInformation") val paymentInformation: PaymentInformation? = null, + @SerializedName("paymentPreauthInformation") val paymentPreauthInformation: JsonObject? = null, + @SerializedName("exitToken") val exitToken: ExitToken? = null, + @SerializedName("paymentState") val paymentState: CheckState? = null, + @SerializedName("pricing") val pricing: Pricing? = null, + @SerializedName("routingTarget") val routingTarget: RoutingTarget? = null, + @SerializedName("paymentResult") val paymentResult: PaymentResult? = null, + @SerializedName("fulfillments") val fulfillments: List = emptyList(), ) { val selfLink: String? get() = links?.get("self")?.href @@ -396,5 +393,5 @@ data class CheckoutProcessResponse( } data class Pricing( - val price: Price? = null, + @SerializedName("price") val price: Price? = null, ) diff --git a/core/src/main/java/io/snabble/sdk/checkout/PersistentState.kt b/core/src/main/java/io/snabble/sdk/checkout/PersistentState.kt index fe3f5b92a7..17ea385eab 100644 --- a/core/src/main/java/io/snabble/sdk/checkout/PersistentState.kt +++ b/core/src/main/java/io/snabble/sdk/checkout/PersistentState.kt @@ -1,5 +1,7 @@ package io.snabble.sdk.checkout +import androidx.annotation.Keep +import com.google.gson.annotations.SerializedName import io.snabble.sdk.PaymentMethod import io.snabble.sdk.Product import io.snabble.sdk.coupons.Coupon @@ -10,20 +12,21 @@ import io.snabble.sdk.utils.GsonHolder import io.snabble.sdk.utils.Logger import java.io.File +@Keep data class PersistentState( @Transient var file: File, - var cartId: String? = null, - var checkoutProcess: CheckoutProcessResponse? = null, - var selectedPaymentMethod: PaymentMethod? = null, - var priceToPay: Int = 0, - var codes: List = mutableListOf(), - var invalidProducts: List? = null, - var invalidItems: List? = null, - var redeemedCoupons: List = emptyList(), - var state: CheckoutState = CheckoutState.NONE, - var fulfillmentState: List? = null, - var signedCheckoutInfo: SignedCheckoutInfo? = null + @SerializedName("cartId") var cartId: String? = null, + @SerializedName("checkoutProcess") var checkoutProcess: CheckoutProcessResponse? = null, + @SerializedName("selectedPaymentMethod") var selectedPaymentMethod: PaymentMethod? = null, + @SerializedName("priceToPay") var priceToPay: Int = 0, + @SerializedName("codes") var codes: List = mutableListOf(), + @SerializedName("invalidProducts") var invalidProducts: List? = null, + @SerializedName("invalidItems") var invalidItems: List? = null, + @SerializedName("redeemedCoupons") var redeemedCoupons: List = emptyList(), + @SerializedName("state") var state: CheckoutState = CheckoutState.NONE, + @SerializedName("fulfillmentState") var fulfillmentState: List? = null, + @SerializedName("signedCheckoutInfo") var signedCheckoutInfo: SignedCheckoutInfo? = null ) { fun save() { diff --git a/core/src/main/java/io/snabble/sdk/codes/ScannedCode.kt b/core/src/main/java/io/snabble/sdk/codes/ScannedCode.kt index 44c76c92a0..f97800886f 100644 --- a/core/src/main/java/io/snabble/sdk/codes/ScannedCode.kt +++ b/core/src/main/java/io/snabble/sdk/codes/ScannedCode.kt @@ -1,5 +1,6 @@ package io.snabble.sdk.codes +import androidx.annotation.Keep import io.snabble.sdk.Project import io.snabble.sdk.Unit import java.io.Serializable @@ -10,6 +11,7 @@ import java.math.BigDecimal /** * Class representing a scanned code, including its potentially embedded data */ +@Keep class ScannedCode private constructor() : Serializable { private var _embeddedData: Int? = null diff --git a/core/src/main/java/io/snabble/sdk/coupons/Coupon.kt b/core/src/main/java/io/snabble/sdk/coupons/Coupon.kt index a1d7baf316..b702200d04 100644 --- a/core/src/main/java/io/snabble/sdk/coupons/Coupon.kt +++ b/core/src/main/java/io/snabble/sdk/coupons/Coupon.kt @@ -11,36 +11,34 @@ import kotlinx.parcelize.Parcelize import java.time.ZonedDateTime @Parcelize -data class Coupon ( - val id: String, - val name: String, - val description: String?, - val promotionDescription: String?, - val type: CouponType, - val codes: List?, - val code: String?, - @SerializedName("validFrom") - private val _validFrom: String?, - @SerializedName("validUntil") - private val _validUntil: String?, - val image: CouponImage?, - val disclaimer: String?, - val colors: Map?, +data class Coupon( + @SerializedName("id") val id: String, + @SerializedName("name") val name: String, + @SerializedName("description") val description: String?, + @SerializedName("promotionDescription") val promotionDescription: String?, + @SerializedName("type") val type: CouponType, + @SerializedName("codes") val codes: List?, + @SerializedName("code") val code: String?, + @SerializedName("validFrom") private val _validFrom: String?, + @SerializedName("validUntil") private val _validUntil: String?, + @SerializedName("image") val image: CouponImage?, + @SerializedName("disclaimer") val disclaimer: String?, + @SerializedName("colors") val colors: Map?, ) : Parcelable { val isValid: Boolean - get() = when(type) { - CouponType.DIGITAL -> image != null - CouponType.MANUAL, - CouponType.PRINTED -> true - } + get() = when (type) { + CouponType.DIGITAL -> image != null + CouponType.MANUAL, + CouponType.PRINTED -> true + } @IgnoredOnParcel val validFrom: ZonedDateTime? - get() = _validFrom?.let { ZonedDateTime.parse(_validFrom)} + get() = _validFrom?.let { ZonedDateTime.parse(_validFrom) } @IgnoredOnParcel val validUntil: ZonedDateTime? - get() = _validUntil?.let { ZonedDateTime.parse(_validUntil)} + get() = _validUntil?.let { ZonedDateTime.parse(_validUntil) } @IgnoredOnParcel val backgroundColor @@ -52,51 +50,51 @@ data class Coupon ( } @Parcelize -data class CouponCode ( - val code: String, - val template: String, +data class CouponCode( + @SerializedName("code") val code: String, + @SerializedName("template") val template: String, ) : Parcelable @Parcelize -data class CouponImage ( - val name: String?, - val formats: List, +data class CouponImage( + @SerializedName("name") val name: String?, + @SerializedName("formats") val formats: List, ) : Parcelable { val bestResolutionUrl: String - get() { - val res = Snabble.application.resources + get() { + val res = Snabble.application.resources - val mdpiRange = 0..DisplayMetrics.DENSITY_MEDIUM - val hdpiRange = DisplayMetrics.DENSITY_MEDIUM..DisplayMetrics.DENSITY_HIGH - val xhdpiRange = DisplayMetrics.DENSITY_HIGH..DisplayMetrics.DENSITY_XHIGH - val xxhdpiRange = DisplayMetrics.DENSITY_XHIGH..DisplayMetrics.DENSITY_XXHIGH - val xxxhdpiRange = DisplayMetrics.DENSITY_XXXHIGH..Int.MAX_VALUE + val mdpiRange = 0..DisplayMetrics.DENSITY_MEDIUM + val hdpiRange = DisplayMetrics.DENSITY_MEDIUM..DisplayMetrics.DENSITY_HIGH + val xhdpiRange = DisplayMetrics.DENSITY_HIGH..DisplayMetrics.DENSITY_XHIGH + val xxhdpiRange = DisplayMetrics.DENSITY_XHIGH..DisplayMetrics.DENSITY_XXHIGH + val xxxhdpiRange = DisplayMetrics.DENSITY_XXXHIGH..Int.MAX_VALUE - val preferredDpi = when (res.displayMetrics.densityDpi) { - in mdpiRange -> "mdpi" - in hdpiRange -> "hdpi" - in xhdpiRange -> "xhdpi" - in xxhdpiRange -> "xxhdpi" - in xxxhdpiRange -> "xxxhdpi" - else -> null - } + val preferredDpi = when (res.displayMetrics.densityDpi) { + in mdpiRange -> "mdpi" + in hdpiRange -> "hdpi" + in xhdpiRange -> "xhdpi" + in xxhdpiRange -> "xxhdpi" + in xxxhdpiRange -> "xxxhdpi" + else -> null + } - val image = formats - .filter { it.contentType == "image/webp" } - .firstOrNull { it.size == preferredDpi } - ?: this.formats.last() + val image = formats + .filter { it.contentType == "image/webp" } + .firstOrNull { it.size == preferredDpi } + ?: this.formats.last() - return image.url - } + return image.url + } } @Parcelize -data class CouponImageFormats ( - val contentType: String, - val width: Int?, - val height: Int?, - val size: String, - val url: String, +data class CouponImageFormats( + @SerializedName("contentType") val contentType: String, + @SerializedName("width") val width: Int?, + @SerializedName("height") val height: Int?, + @SerializedName("size") val size: String, + @SerializedName("url") val url: String, ) : Parcelable enum class CouponType { diff --git a/core/src/main/java/io/snabble/sdk/payment/PaymentCredentials.java b/core/src/main/java/io/snabble/sdk/payment/PaymentCredentials.java index 5e7de48dcb..1a13a6b766 100644 --- a/core/src/main/java/io/snabble/sdk/payment/PaymentCredentials.java +++ b/core/src/main/java/io/snabble/sdk/payment/PaymentCredentials.java @@ -2,10 +2,13 @@ import android.util.Base64; +import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RestrictTo; +import com.google.gson.annotations.SerializedName; + import java.io.InputStream; import java.security.cert.CertPath; import java.security.cert.CertPathValidator; @@ -50,6 +53,7 @@ /** * Class for storing encrypting payment credentials */ +@Keep public class PaymentCredentials { /** * Enum describing the type of the payment credentials @@ -136,26 +140,26 @@ public static Brand fromPaymentMethod(PaymentMethod paymentMethod) { } private static class SepaData { - private String name; - private String iban; + @SerializedName("name") private String name; + @SerializedName("iban") private String iban; } private static class CreditCardData { - private String hostedDataID; - private String schemeTransactionID; - private String projectID; - private String hostedDataStoreID; - private String cardType; + @SerializedName("hostedDataID") private String hostedDataID; + @SerializedName("schemeTransactionID") private String schemeTransactionID; + @SerializedName("projectID") private String projectID; + @SerializedName("hostedDataStoreID") private String hostedDataStoreID; + @SerializedName("cardType") private String cardType; } private static class DatatransData { - private String alias; - private String expiryMonth; - private String expiryYear; + @SerializedName("alias") private String alias; + @SerializedName("expiryMonth") private String expiryMonth; + @SerializedName("expiryYear") private String expiryYear; } private static class TegutEmployeeCard { - private String cardNumber; + @SerializedName("cardNumber") private String cardNumber; } private String obfuscatedId; diff --git a/core/src/main/java/io/snabble/sdk/payment/PaymentCredentialsStore.java b/core/src/main/java/io/snabble/sdk/payment/PaymentCredentialsStore.java index 2bb68cc54f..c97196cf16 100644 --- a/core/src/main/java/io/snabble/sdk/payment/PaymentCredentialsStore.java +++ b/core/src/main/java/io/snabble/sdk/payment/PaymentCredentialsStore.java @@ -6,6 +6,7 @@ import android.content.SharedPreferences; import android.os.Build; +import androidx.annotation.Keep; import androidx.annotation.RestrictTo; import com.google.gson.Gson; @@ -30,6 +31,7 @@ * Class for managing and storing payment credentials. */ public class PaymentCredentialsStore { + @Keep private class Data { private List credentialsList; private String id; diff --git a/core/src/main/java/io/snabble/sdk/payment/data/GiropayAuthorizationData.kt b/core/src/main/java/io/snabble/sdk/payment/data/GiropayAuthorizationData.kt index 84624b1e1d..cd26286416 100644 --- a/core/src/main/java/io/snabble/sdk/payment/data/GiropayAuthorizationData.kt +++ b/core/src/main/java/io/snabble/sdk/payment/data/GiropayAuthorizationData.kt @@ -1,11 +1,13 @@ package io.snabble.sdk.payment.data +import com.google.gson.annotations.SerializedName + data class GiropayAuthorizationData( - @JvmField val id: String, - @JvmField val name: String, - @JvmField val ipAddress: String, - @JvmField val fingerprint: String, - @JvmField val redirectUrlAfterSuccess: String, - @JvmField val redirectUrlAfterCancellation: String, - @JvmField val redirectUrlAfterFailure: String + @JvmField @SerializedName("id") val id: String, + @JvmField @SerializedName("name") val name: String, + @JvmField @SerializedName("ipAddress") val ipAddress: String, + @JvmField @SerializedName("fingerprint") val fingerprint: String, + @JvmField @SerializedName("redirectUrlAfterSuccess") val redirectUrlAfterSuccess: String, + @JvmField @SerializedName("redirectUrlAfterCancellation") val redirectUrlAfterCancellation: String, + @JvmField @SerializedName("redirectUrlAfterFailure") val redirectUrlAfterFailure: String ) diff --git a/core/src/main/java/io/snabble/sdk/payment/data/GiropayData.kt b/core/src/main/java/io/snabble/sdk/payment/data/GiropayData.kt index 779ecd6b22..6c4d53f394 100644 --- a/core/src/main/java/io/snabble/sdk/payment/data/GiropayData.kt +++ b/core/src/main/java/io/snabble/sdk/payment/data/GiropayData.kt @@ -1,8 +1,9 @@ package io.snabble.sdk.payment.data +import com.google.gson.annotations.SerializedName + data class GiropayData( - @JvmField val clientID: String?, - @JvmField val customerAuthorizationURI: String, - @JvmField val authorizationData: GiropayAuthorizationData? = null, + @JvmField @SerializedName("clientID") val clientID: String?, + @JvmField @SerializedName("customerAuthorizationURI") val customerAuthorizationURI: String, + @JvmField @SerializedName("authorizationData") val authorizationData: GiropayAuthorizationData? = null, ) - diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCart.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCart.kt index 836bd62451..a500c68da9 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCart.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCart.kt @@ -1,5 +1,6 @@ package io.snabble.sdk.shoppingcart +import androidx.annotation.Keep import androidx.annotation.RestrictTo import io.snabble.sdk.PriceFormatter import io.snabble.sdk.Product @@ -947,6 +948,7 @@ class ShoppingCart( /** * Class describing a shopping cart item */ + @Keep class Item { /** diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCartData.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCartData.kt index 6e4bb7ae68..58f11428c4 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCartData.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/ShoppingCartData.kt @@ -1,11 +1,13 @@ package io.snabble.sdk.shoppingcart +import androidx.annotation.Keep import io.snabble.sdk.Product import io.snabble.sdk.ViolationNotification import io.snabble.sdk.shoppingcart.data.Taxation import io.snabble.sdk.utils.GsonHolder import java.util.UUID +@Keep data class ShoppingCartData @JvmOverloads constructor( val id: String = UUID.randomUUID().toString(), val uuid: String = UUID.randomUUID().toString(), diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/data/Taxation.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/data/Taxation.kt index 907451f825..532a69d2b6 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/data/Taxation.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/data/Taxation.kt @@ -1,12 +1,14 @@ package io.snabble.sdk.shoppingcart.data +import com.google.gson.annotations.SerializedName + /** * Enum describing the type of taxation */ enum class Taxation(val value: String) { - UNDECIDED("undecided"), - IN_HOUSE("inHouse"), - TAKEAWAY("takeaway") + @SerializedName("undecided") UNDECIDED("undecided"), + @SerializedName("inHouse") IN_HOUSE("inHouse"), + @SerializedName("takeaway") TAKEAWAY("takeaway") } diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCart.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCart.kt index b53fa536ac..2bd3c56085 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCart.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCart.kt @@ -10,10 +10,10 @@ import io.snabble.sdk.shoppingcart.data.item.BackendCartItem data class BackendCart( @SerializedName("appUserID") val appUserId: String? = null, @SerializedName("clientID") val clientId: String? = null, - val customer: BackendCartCustomer? = null, - override val eventType: EventType = EventType.CART, - @JvmField val items: List, - val requiredInformation: List, - val session: String, + @SerializedName("customer") val customer: BackendCartCustomer? = null, + @SerializedName("eventType") override val eventType: EventType = EventType.CART, + @JvmField @SerializedName("items") val items: List, + @SerializedName("requiredInformation") val requiredInformation: List, + @SerializedName("session") val session: String, @SerializedName("shopID") val shopId: String ) : Payload diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartCustomer.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartCustomer.kt index 93712af307..7ae9e5d05d 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartCustomer.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartCustomer.kt @@ -1,8 +1,9 @@ package io.snabble.sdk.shoppingcart.data.cart import androidx.annotation.RestrictTo +import com.google.gson.annotations.SerializedName @RestrictTo(RestrictTo.Scope.LIBRARY) data class BackendCartCustomer( - val loyaltyCard: String + @SerializedName("loyaltyCard") val loyaltyCard: String ) diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartRequiredInformation.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartRequiredInformation.kt index 950b6aa9a4..0946262532 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartRequiredInformation.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/data/cart/BackendCartRequiredInformation.kt @@ -1,9 +1,10 @@ package io.snabble.sdk.shoppingcart.data.cart import androidx.annotation.RestrictTo +import com.google.gson.annotations.SerializedName @RestrictTo(RestrictTo.Scope.LIBRARY) data class BackendCartRequiredInformation( - val id: String, - val value: String + @SerializedName("id") val id: String, + @SerializedName("value") val value: String ) diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/BackendCartItem.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/BackendCartItem.kt index 8108e62cff..1942f9e17f 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/BackendCartItem.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/BackendCartItem.kt @@ -5,18 +5,18 @@ import com.google.gson.annotations.SerializedName @RestrictTo(RestrictTo.Scope.LIBRARY) data class BackendCartItem( - val id: String? = null, - val sku: String? = null, + @SerializedName("id") val id: String? = null, + @SerializedName("sku") val sku: String? = null, @JvmField @SerializedName("ItemID") val itemId: String? = null, - val type: BackendCartItemType? = null, - @JvmField val scannedCode: String? = null, - @JvmField val amount: Int = 0, - @JvmField val weightUnit: String? = null, - @JvmField val price: Int? = null, - @JvmField val weight: Int? = null, - @JvmField val units: Int? = null, - val refersTo: String? = null, - val couponID: String? = null + @SerializedName("type") val type: BackendCartItemType? = null, + @JvmField @SerializedName("scannedCode") val scannedCode: String? = null, + @JvmField @SerializedName("amount") val amount: Int = 0, + @JvmField @SerializedName("weightUnit") val weightUnit: String? = null, + @JvmField @SerializedName("price") val price: Int? = null, + @JvmField @SerializedName("weight") val weight: Int? = null, + @JvmField @SerializedName("units") val units: Int? = null, + @SerializedName("refersTo") val refersTo: String? = null, + @SerializedName("couponID") val couponID: String? = null ) enum class BackendCartItemType { diff --git a/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/DepositReturnVoucher.kt b/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/DepositReturnVoucher.kt index e3433fcdcd..e61acae6d0 100644 --- a/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/DepositReturnVoucher.kt +++ b/core/src/main/java/io/snabble/sdk/shoppingcart/data/item/DepositReturnVoucher.kt @@ -1,7 +1,9 @@ package io.snabble.sdk.shoppingcart.data.item +import androidx.annotation.Keep import io.snabble.sdk.checkout.LineItem +@Keep data class DepositReturnVoucher( val itemId: String, val scannedCode: String, diff --git a/gradle.properties b/gradle.properties index 29a6bee0b6..25e9a2c0b0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,5 +17,3 @@ org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 android.useAndroidX=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -android.nonTransitiveRClass=false -android.nonFinalResIds=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3dbde257c6..d400b33380 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ compileSdk = "36" targetSdk = "36" minSdk = "24" -gradlePlugin = "8.13.2" +gradlePlugin = "9.2.1" kotlin = "2.3.0" navigation = "2.9.6" snabbleSdk = "0.69.6" @@ -97,8 +97,7 @@ kotlinx-serializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1. mockk = "io.mockk:mockk:1.14.7" # @pin requires higher target mockito-kotlin = "org.mockito.kotlin:mockito-kotlin:6.1.0" -roboletric = "org.robolectric:robolectric:4.16" -roboletric-androidAll = "org.robolectric:android-all:13-robolectric-9030017" +roboletric = "org.robolectric:robolectric:4.16.1" sebaslogen-resaca = "io.github.sebaslogen:resaca:4.7.0" squareup-okhttp3-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "com-squareup-okhttp3" } test-espressoCore = "androidx.test.espresso:espresso-core:3.7.0" @@ -155,7 +154,7 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -snabbleSetup = "io.snabble.setup:1.0.1" +snabbleSetup = "io.snabble.setup:1.0.3" unmock = "de.mobilej.unmock:0.7.9" benManesVersions = "com.github.ben-manes.versions:0.53.0" versionCatalogUpdate = "nl.littlerobots.version-catalog-update:1.0.1" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60c75..d997cfc60f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2a84e188b8..5dd3c0121b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index ef07e0162b..739907dfd1 100755 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" diff --git a/gradlew.bat b/gradlew.bat index db3a6ac207..c4bdd3ab8e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,10 @@ goto fail :execute @rem Setup the command line -set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/kotlin-sample/build.gradle.kts b/kotlin-sample/build.gradle.kts index dc2c557350..48cfdc2830 100644 --- a/kotlin-sample/build.gradle.kts +++ b/kotlin-sample/build.gradle.kts @@ -2,7 +2,6 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id(libs.plugins.androidApplication.get().pluginId) - id(libs.plugins.kotlin.android.get().pluginId) alias(libs.plugins.snabbleSetup) alias(libs.plugins.compose.compiler) } @@ -30,30 +29,32 @@ android { release { signingConfig = signingConfigs.getByName("debug") isMinifyEnabled = true + isShrinkResources = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } } compileOptions { isCoreLibraryDesugaringEnabled = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } - kotlin { - compilerOptions { - jvmTarget = JvmTarget.JVM_17 - freeCompilerArgs.addAll( - "-Xjvm-default=all" - ) - } - } buildFeatures { buildConfig = true } } +kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_21 + freeCompilerArgs.addAll( + "-jvm-default=enable" + ) + } +} + snabble { production { appId = "snabble-sdk-demo-app-oguh3x" diff --git a/kotlin-sample/src/main/java/io/snabble/sdk/sample/MainActivity.kt b/kotlin-sample/src/main/java/io/snabble/sdk/sample/MainActivity.kt index 103d807b7a..85008344eb 100644 --- a/kotlin-sample/src/main/java/io/snabble/sdk/sample/MainActivity.kt +++ b/kotlin-sample/src/main/java/io/snabble/sdk/sample/MainActivity.kt @@ -36,6 +36,7 @@ import io.snabble.sdk.screens.receipts.showDetails import io.snabble.sdk.widgets.snabble.devsettings.login.ui.DevSettingsLoginFragment import io.snabble.sdk.widgets.snabble.devsettings.login.viewmodel.DevSettingsLoginViewModel import kotlinx.coroutines.launch +import io.snabble.sdk.ui.toolkit.R as UiToolkitR class MainActivity : AppCompatActivity() { @@ -97,7 +98,7 @@ class MainActivity : AppCompatActivity() { SnabbleUiToolkit.executeAction( context = this@MainActivity, SnabbleUiToolkit.Event.SHOW_ONBOARDING, - bundleOf(getString(R.string.bundle_key_model) to model) + bundleOf(getString(UiToolkitR.string.bundle_key_model) to model) ) } } @@ -133,6 +134,7 @@ class MainActivity : AppCompatActivity() { } } } + else -> Unit } } @@ -149,6 +151,7 @@ class MainActivity : AppCompatActivity() { DevSettingsLoginFragment().show(supportFragmentManager, "DevSettingsPasswordDialog") } } + else -> Unit } } @@ -160,12 +163,15 @@ class MainActivity : AppCompatActivity() { "io.snabble.environment.production" -> { Environment.PRODUCTION } + "io.snabble.environment.staging" -> { Environment.STAGING } + "io.snabble.environment.testing" -> { Environment.TESTING } + else -> return } if (environment != Snabble.environment) { diff --git a/mlkit-scanner-engine/build.gradle.kts b/mlkit-scanner-engine/build.gradle.kts index 7915de9ea1..0f3fde38d6 100644 --- a/mlkit-scanner-engine/build.gradle.kts +++ b/mlkit-scanner-engine/build.gradle.kts @@ -1,16 +1,11 @@ -@file:Suppress("UnstableApiUsage") - import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id(libs.plugins.androidLibrary.get().pluginId) - id(libs.plugins.kotlin.android.get().pluginId) id(libs.plugins.dokka.get().pluginId) } -apply { - from("../scripts/maven.gradle") -} +apply(from = "../scripts/maven.gradle") description = "ML Kit Scanner Engine: The ML Kit scanner engine implementation for the Snabble SDK" @@ -39,15 +34,15 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlin { compilerOptions { - jvmTarget = JvmTarget.JVM_17 + jvmTarget = JvmTarget.JVM_21 freeCompilerArgs.addAll( - "-Xjvm-default=all" + "-jvm-default=enable" ) } } diff --git a/scripts/maven.gradle b/scripts/maven.gradle index fc44600b01..b7b9205500 100644 --- a/scripts/maven.gradle +++ b/scripts/maven.gradle @@ -1,6 +1,12 @@ version = project.sdkVersion group = 'io.snabble.sdk' +android { + publishing { + singleVariant("release") + } +} + afterEvaluate { publishing { publications { diff --git a/settings.gradle.kts b/settings.gradle.kts index 174eb57dbf..64007c00ca 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,11 +3,6 @@ pluginManagement { mavenLocal() gradlePluginPortal() } - plugins { - id("org.jetbrains.dokka") version "1.8.10" - id("com.android.application") version "7.4.1" - id("org.jetbrains.kotlin.android") version "1.8.10" - } } include( diff --git a/ui-toolkit/build.gradle.kts b/ui-toolkit/build.gradle.kts index e45927855d..ecf0a11888 100644 --- a/ui-toolkit/build.gradle.kts +++ b/ui-toolkit/build.gradle.kts @@ -1,19 +1,14 @@ -@file:Suppress("UnstableApiUsage") - import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id(libs.plugins.androidLibrary.get().pluginId) - id(libs.plugins.kotlin.android.get().pluginId) id(libs.plugins.dokka.get().pluginId) id(libs.plugins.kotlin.parcelize.get().pluginId) alias(libs.plugins.kotlin.serialization) alias(libs.plugins.compose.compiler) } -apply { - from("../scripts/maven.gradle") -} +apply(from = "../scripts/maven.gradle") description = "Snabble UI-Toolkit: Additional views for simple and sample apps using the Snabble SDK" @@ -41,22 +36,16 @@ android { } } - sourceSets { - getByName("main").java.srcDirs("src/main/kotlin") - getByName("test").java.srcDirs("src/test/kotlin") - getByName("androidTest").java.srcDirs("src/androidTest/kotlin") - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlin { compilerOptions { - jvmTarget = JvmTarget.JVM_17 + jvmTarget = JvmTarget.JVM_21 freeCompilerArgs.addAll( - "-Xjvm-default=all" + "-jvm-default=enable" ) } } diff --git a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/notckeckedin/NotCheckedInFragment.kt b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/notckeckedin/NotCheckedInFragment.kt index 8a7ffb407c..6475bab9a3 100644 --- a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/notckeckedin/NotCheckedInFragment.kt +++ b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/notckeckedin/NotCheckedInFragment.kt @@ -32,6 +32,7 @@ import androidx.fragment.app.Fragment import io.snabble.sdk.SnabbleUiToolkit import io.snabble.sdk.dynamicview.theme.ThemeWrapper import io.snabble.sdk.ui.toolkit.R +import io.snabble.sdk.ui.R as UiR class NotCheckedInFragment : Fragment() { @@ -53,18 +54,21 @@ fun NotCheckedInScreen() { Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally) + horizontalAlignment = Alignment.CenterHorizontally + ) { Image( modifier = Modifier.padding(16.dp, 16.dp, 16.dp, 16.dp), painter = painterResource(id = R.drawable.snabble_offline_shop), colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.primary), - contentDescription = "Store") + contentDescription = "Store" + ) Text( modifier = Modifier.padding(16.dp, 16.dp, 16.dp, 8.dp), text = stringResource(id = R.string.Snabble_Scanner_notCheckedIn), color = MaterialTheme.colorScheme.onSurface, - textAlign = TextAlign.Center) + textAlign = TextAlign.Center + ) Box( modifier = Modifier .fillMaxWidth() @@ -80,7 +84,7 @@ fun NotCheckedInScreen() { ) { Text( modifier = Modifier.align(Alignment.Center), - text = stringResource(id = R.string.Snabble_DynamicView_Shop_show), + text = stringResource(id = UiR.string.Snabble_DynamicView_Shop_show), style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary ) diff --git a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingItem.kt b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingItem.kt index 73af918953..0f1b014b9b 100644 --- a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingItem.kt +++ b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingItem.kt @@ -1,6 +1,7 @@ package io.snabble.sdk.screens.onboarding.data import android.os.Parcelable +import com.google.gson.annotations.SerializedName import kotlinx.parcelize.Parcelize /** @@ -20,11 +21,11 @@ import kotlinx.parcelize.Parcelize */ @Parcelize data class OnboardingItem( - val imageSource: String?, - val title: String?, - val text: String?, - val footer: String?, - val customButtonTitle: String?, - val termsButtonTitle: String?, - val link: String? -) : Parcelable \ No newline at end of file + @SerializedName ("imageSource") val imageSource: String?, + @SerializedName ("title")val title: String?, + @SerializedName ("text")val text: String?, + @SerializedName ("footer")val footer: String?, + @SerializedName ("customButtonTitle")val customButtonTitle: String?, + @SerializedName ("termsButtonTitle")val termsButtonTitle: String?, + @SerializedName ("link")val link: String? +) : Parcelable diff --git a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingModel.kt b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingModel.kt index d23e4a6446..71e4239581 100644 --- a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingModel.kt +++ b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/data/OnboardingModel.kt @@ -1,6 +1,7 @@ package io.snabble.sdk.screens.onboarding.data import android.os.Parcelable +import com.google.gson.annotations.SerializedName import kotlinx.parcelize.Parcelize /** @@ -8,6 +9,6 @@ import kotlinx.parcelize.Parcelize */ @Parcelize data class OnboardingModel( - val configuration: OnboardingConfiguration?, - val items: List -) : Parcelable \ No newline at end of file + @SerializedName ("configuration")val configuration: OnboardingConfiguration?, + @SerializedName ("items")val items: List +) : Parcelable diff --git a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/ui/terms/RawHtmlFragment.kt b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/ui/terms/RawHtmlFragment.kt index d92a39bf11..6ce1494b05 100644 --- a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/ui/terms/RawHtmlFragment.kt +++ b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/onboarding/ui/terms/RawHtmlFragment.kt @@ -10,10 +10,12 @@ import android.view.ViewGroup import android.webkit.WebResourceRequest import android.webkit.WebView import android.webkit.WebViewClient +import androidx.core.net.toUri import androidx.fragment.app.Fragment import io.snabble.sdk.ui.toolkit.R import io.snabble.sdk.utils.getColorByAttribute -import androidx.core.net.toUri +import androidx.appcompat.R as AppCompatR +import com.google.android.material.R as MaterialR /** Displays any given HTML in a [WebView] */ abstract class RawHtmlFragment : Fragment() { @@ -33,7 +35,7 @@ abstract class RawHtmlFragment : Fragment() { super.onViewCreated(view, savedInstanceState) webView = view.findViewById(R.id.web_view) - webView.setBackgroundColor(requireContext().getColorByAttribute(R.attr.colorSurface)) + webView.setBackgroundColor(requireContext().getColorByAttribute(MaterialR.attr.colorSurface)) webView.webViewClient = object : WebViewClient() { override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest) = shouldOverrideUrlLoading(request.url) @@ -60,7 +62,7 @@ abstract class RawHtmlFragment : Fragment() { else -> "" } - val attrs = intArrayOf(R.attr.colorPrimary) + val attrs = intArrayOf(AppCompatR.attr.colorPrimary) val arr = requireContext().obtainStyledAttributes(attrs) val primaryColor = arr.getColor(0, -1) arr.recycle() diff --git a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptItemHelper.kt b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptItemHelper.kt index 880c0da585..71480ea891 100644 --- a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptItemHelper.kt +++ b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptItemHelper.kt @@ -10,8 +10,10 @@ import io.snabble.sdk.widgets.snabble.purchase.RelativeTimeStringFormatterImpl import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import java.text.SimpleDateFormat -import java.util.* +import java.util.Date +import java.util.Locale import kotlin.time.Duration.Companion.days +import io.snabble.sdk.ui.R as UiR internal class ReceiptItemHelper( private val context: Context, @@ -50,7 +52,7 @@ internal class ReceiptItemHelper( newLineTimestamp -> DATE_FORMAT_NEW_LINE.format(past) - else -> "${DATE_FORMAT.format(past)} ${context.getString(R.string.Snabble_Receipts_oClock)}" + else -> "${DATE_FORMAT.format(past)} ${context.getString(UiR.string.Snabble_Receipts_oClock)}" } } diff --git a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptProvider.kt b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptProvider.kt index 2564667b36..67bc5aaf64 100644 --- a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptProvider.kt +++ b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/receipts/ReceiptProvider.kt @@ -25,6 +25,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine import java.io.File import kotlin.coroutines.coroutineContext import kotlin.coroutines.resumeWithException +import io.snabble.sdk.ui.R as UiR class ReceiptProvider( private val context: Context, @@ -59,7 +60,7 @@ class ReceiptProvider( receiptInfo() ?.let { getReceipts(it) } } catch (e: DownloadFailedException) { - showSnackBar(view, R.string.Snabble_Receipt_errorDownload) + showSnackBar(view, UiR.string.Snabble_Receipt_errorDownload) null } finally { dialogJob.cancel() @@ -68,7 +69,7 @@ class ReceiptProvider( try { show(receipt) } catch (e: MissingPdfReaderException) { - showSnackBar(view, R.string.Snabble_Receipt_pdfReaderUnavailable) + showSnackBar(view, UiR.string.Snabble_Receipt_pdfReaderUnavailable) } } } diff --git a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/shopfinder/ShopDetailsFragment.kt b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/shopfinder/ShopDetailsFragment.kt index 2446c2004b..9d6036b1b1 100644 --- a/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/shopfinder/ShopDetailsFragment.kt +++ b/ui-toolkit/src/main/kotlin/io/snabble/sdk/screens/shopfinder/ShopDetailsFragment.kt @@ -28,7 +28,11 @@ import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.GoogleMap.OnCameraMoveStartedListener import com.google.android.gms.maps.MapView -import com.google.android.gms.maps.model.* +import com.google.android.gms.maps.model.BitmapDescriptorFactory +import com.google.android.gms.maps.model.CameraPosition +import com.google.android.gms.maps.model.LatLng +import com.google.android.gms.maps.model.MapStyleOptions +import com.google.android.gms.maps.model.MarkerOptions import com.google.android.material.bottomsheet.BottomSheetBehavior import io.snabble.accessibility.isTalkBackActive import io.snabble.accessibility.setClickDescription @@ -54,7 +58,10 @@ import kotlinx.coroutines.launch import java.text.DateFormatSymbols import java.text.ParseException import java.text.SimpleDateFormat -import java.util.* +import java.util.Collections +import java.util.GregorianCalendar +import java.util.Locale +import io.snabble.sdk.ui.R as UiR /** * Displays the details of the selected shop. @@ -370,7 +377,7 @@ open class ShopDetailsFragment : Fragment() { } val startScanner = view.findViewById