diff --git a/build.gradle b/build.gradle index a85eb207f..0e7856f0b 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { ext.lifecycle_version = '2.0.0' ext.material_version = '1.0.0' ext.mockito_version = '2.18.3' - ext.moshi_version = '1.6.0' + ext.moshi_version = '1.8.0' ext.okhttp3_version = '4.1.0' ext.realm_version = '5.8.0' ext.realm_adapters_version = '3.1.0' diff --git a/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt b/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt index bc01d68b8..b81a7c831 100644 --- a/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/manager/ChangelogManagerImpl.kt @@ -22,6 +22,7 @@ import android.content.Context import com.moez.QKSMS.common.util.extensions.versionCode import com.moez.QKSMS.util.Preferences import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.squareup.moshi.Moshi import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers @@ -88,15 +89,18 @@ class ChangelogManagerImpl @Inject constructor( prefs.changelogVersion.set(context.versionCode) } - private data class ChangelogResponse( + @JsonClass(generateAdapter = true) + data class ChangelogResponse( @Json(name = "documents") val documents: List ) - private data class Document( + @JsonClass(generateAdapter = true) + data class Document( @Json(name = "fields") val fields: Changelog ) - private data class Changelog( + @JsonClass(generateAdapter = true) + data class Changelog( @Json(name = "added") val added: ArrayField?, @Json(name = "improved") val improved: ArrayField?, @Json(name = "fixed") val fixed: ArrayField?, @@ -104,19 +108,23 @@ class ChangelogManagerImpl @Inject constructor( @Json(name = "versionCode") val versionCode: IntegerField ) - private data class ArrayField( + @JsonClass(generateAdapter = true) + data class ArrayField( @Json(name = "arrayValue") val value: ArrayValues ) - private data class ArrayValues( + @JsonClass(generateAdapter = true) + data class ArrayValues( @Json(name = "values") val values: List ) - private data class StringField( + @JsonClass(generateAdapter = true) + data class StringField( @Json(name = "stringValue") val value: String ) - private data class IntegerField( + @JsonClass(generateAdapter = true) + data class IntegerField( @Json(name = "integerValue") val value: String ) diff --git a/presentation/build.gradle b/presentation/build.gradle index c8e92e77e..f089c8a75 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -160,12 +160,16 @@ dependencies { testImplementation "junit:junit:$junit_version" testImplementation "org.mockito:mockito-core:$mockito_version" + // moshi + implementation "com.squareup.moshi:moshi:$moshi_version" + debugImplementation "com.squareup.moshi:moshi-kotlin:$moshi_version" + kaptRelease "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version" + implementation "com.android.billingclient:billing:1.0" implementation "com.github.chrisbanes:PhotoView:2.0.0" implementation "com.f2prateek.rx.preferences2:rx-preferences:$rx_preferences_version" implementation "com.google.android:flexbox:0.3.1" implementation "com.jakewharton.timber:timber:$timber_version" - implementation "com.squareup.moshi:moshi:$moshi_version" implementation "com.squareup.moshi:moshi-kotlin:$moshi_version" implementation "me.leolin:ShortcutBadger:1.1.21" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" diff --git a/presentation/proguard-rules.pro b/presentation/proguard-rules.pro index c984dc0aa..5d87be3fe 100644 --- a/presentation/proguard-rules.pro +++ b/presentation/proguard-rules.pro @@ -17,6 +17,7 @@ # okio -dontwarn okio.** +# okhttp3 # JSR 305 annotations are for embedding nullability information. -dontwarn javax.annotation.** @@ -28,3 +29,64 @@ # OkHttp platform used only on JVM and when Conscrypt dependency is available. -dontwarn okhttp3.internal.platform.ConscryptPlatform + +# moshi +# JSR 305 annotations are for embedding nullability information. +-dontwarn javax.annotation.** + +-keepclasseswithmembers class * { + @com.squareup.moshi.* ; +} + +-keep @com.squareup.moshi.JsonQualifier interface * + +# Enum field names are used by the integrated EnumJsonAdapter. +# Annotate enums with @JsonClass(generateAdapter = false) to use them with Moshi. +-keepclassmembers @com.squareup.moshi.JsonClass class * extends java.lang.Enum { + ; +} + +# The name of @JsonClass types is used to look up the generated adapter. +-keepnames @com.squareup.moshi.JsonClass class * + +# Retain generated target class's synthetic defaults constructor and keep DefaultConstructorMarker's +# name. We will look this up reflectively to invoke the type's constructor. +# +# We can't _just_ keep the defaults constructor because Proguard/R8's spec doesn't allow wildcard +# matching preceding parameters. +-keepnames class kotlin.jvm.internal.DefaultConstructorMarker +-keepclassmembers @com.squareup.moshi.JsonClass class * { + (...); +} + +# Retain generated JsonAdapters if annotated type is retained. +-if @com.squareup.moshi.JsonClass class * +-keep class <1>JsonAdapter { + (...); + ; +} +-if @com.squareup.moshi.JsonClass class **$* +-keep class <1>_<2>JsonAdapter { + (...); + ; +} +-if @com.squareup.moshi.JsonClass class **$*$* +-keep class <1>_<2>_<3>JsonAdapter { + (...); + ; +} +-if @com.squareup.moshi.JsonClass class **$*$*$* +-keep class <1>_<2>_<3>_<4>JsonAdapter { + (...); + ; +} +-if @com.squareup.moshi.JsonClass class **$*$*$*$* +-keep class <1>_<2>_<3>_<4>_<5>JsonAdapter { + (...); + ; +} +-if @com.squareup.moshi.JsonClass class **$*$*$*$*$* +-keep class <1>_<2>_<3>_<4>_<5>_<6>JsonAdapter { + (...); + ; +} diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 967b6f6bd..f22519f39 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ +