From 89183c227db7dad484369f2a531495b9bf17e70e Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Tue, 16 Nov 2021 23:01:23 -0500 Subject: [PATCH] Fix proguard serialization issue --- .gitignore | 3 +++ app/build.gradle | 4 ++-- app/src/main/java/io/heckel/ntfy/msg/ApiService.kt | 8 ++++++-- app/src/main/res/values/strings.xml | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0c582a2..af23741 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ google-services.json .keystores/ .signing/ +# Playground +playground/ + # Release app/release/ diff --git a/app/build.gradle b/app/build.gradle index f7b77ec..77fa78a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt index 002611b..a40debd 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt @@ -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, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2340fcf..f48db4d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -51,8 +51,8 @@ Instant delivery in doze mode - 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. Cancel Subscribe