Fix proguard serialization issue

This commit is contained in:
Philipp Heckel 2021-11-16 23:01:23 -05:00
parent 466d7d7b16
commit 89183c227d
4 changed files with 13 additions and 6 deletions

3
.gitignore vendored
View file

@ -5,6 +5,9 @@ google-services.json
.keystores/ .keystores/
.signing/ .signing/
# Playground
playground/
# Release # Release
app/release/ app/release/

View file

@ -12,8 +12,8 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 30
versionCode 2 versionCode 5
versionName "1.0.1" versionName "1.1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View file

@ -1,6 +1,7 @@
package io.heckel.ntfy.msg package io.heckel.ntfy.msg
import android.util.Log import android.util.Log
import androidx.annotation.Keep
import com.google.gson.Gson import com.google.gson.Gson
import io.heckel.ntfy.data.Notification import io.heckel.ntfy.data.Notification
import io.heckel.ntfy.data.topicUrl import io.heckel.ntfy.data.topicUrl
@ -107,10 +108,13 @@ class ApiService {
} }
private fun fromString(subscriptionId: Long, s: String): Notification { private fun fromString(subscriptionId: Long, s: String): Notification {
val n = gson.fromJson(s, Message::class.java) val message = gson.fromJson(s, Message::class.java)
return Notification(n.id, subscriptionId, n.time, n.message, notificationId = 0, deleted = false) return Notification(message.id, subscriptionId, message.time, message.message, notificationId = 0, deleted = false)
} }
/* This annotation ensures that proguard still works in production builds,
* see https://stackoverflow.com/a/62753300/1440785 */
@Keep
private data class Message( private data class Message(
val id: String, val id: String,
val time: Long, val time: Long,

View file

@ -51,8 +51,8 @@
</string> </string>
<string name="add_dialog_instant_delivery">Instant delivery in doze mode</string> <string name="add_dialog_instant_delivery">Instant delivery in doze mode</string>
<string name="add_dialog_instant_delivery_description"> <string name="add_dialog_instant_delivery_description">
Android\'s doze mode sometimes causes delayed message delivery to conserve power. Using this option, notifications are Ensures that messages are immediately delivered, even if the device is inactive or in doze mode.
always immediately delivered. This requires a foreground service and consumes a little more power. This requires a foreground service and consumes a little more power.
</string> </string>
<string name="add_dialog_button_cancel">Cancel</string> <string name="add_dialog_button_cancel">Cancel</string>
<string name="add_dialog_button_subscribe">Subscribe</string> <string name="add_dialog_button_subscribe">Subscribe</string>