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/
.signing/
# Playground
playground/
# Release
app/release/

View file

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

View file

@ -1,6 +1,7 @@
package io.heckel.ntfy.msg
import android.util.Log
import androidx.annotation.Keep
import com.google.gson.Gson
import io.heckel.ntfy.data.Notification
import io.heckel.ntfy.data.topicUrl
@ -107,10 +108,13 @@ class ApiService {
}
private fun fromString(subscriptionId: Long, s: String): Notification {
val n = gson.fromJson(s, Message::class.java)
return Notification(n.id, subscriptionId, n.time, n.message, notificationId = 0, deleted = false)
val message = gson.fromJson(s, Message::class.java)
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(
val id: String,
val time: Long,

View file

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