diff --git a/app/src/main/java/io/heckel/ntfy/data/Database.kt b/app/src/main/java/io/heckel/ntfy/data/Database.kt index d364253..9a98e5d 100644 --- a/app/src/main/java/io/heckel/ntfy/data/Database.kt +++ b/app/src/main/java/io/heckel/ntfy/data/Database.kt @@ -16,7 +16,7 @@ data class Subscription( @Entity data class Notification( - @PrimaryKey val id: Long, // Internal ID, only used in Repository and activities + @PrimaryKey val id: String, @ColumnInfo(name = "subscriptionId") val subscriptionId: Long, @ColumnInfo(name = "timestamp") val timestamp: Long, // Unix timestamp @ColumnInfo(name = "message") val message: String diff --git a/app/src/main/java/io/heckel/ntfy/msg/MessagingService.kt b/app/src/main/java/io/heckel/ntfy/msg/MessagingService.kt index 8e8bd1a..3811d09 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/MessagingService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/MessagingService.kt @@ -36,10 +36,11 @@ class MessagingService : FirebaseMessagingService() { // Check if valid data, and send notification val data = remoteMessage.data + val id = data["id"] val timestamp = data["time"]?.toLongOrNull() val topic = data["topic"] val message = data["message"] - if (topic == null || message == null || timestamp == null) { + if (id == null || topic == null || message == null || timestamp == null) { Log.d(TAG, "Discarding unexpected message: from=${remoteMessage.from}, data=${data}") return } @@ -53,7 +54,7 @@ class MessagingService : FirebaseMessagingService() { repository.updateSubscription(newSubscription) // Add notification - val notification = Notification(id = Random.nextLong(), subscriptionId = subscription.id, timestamp = timestamp, message = message) + val notification = Notification(id = id, subscriptionId = subscription.id, timestamp = timestamp, message = message) repository.addNotification(notification) // Send notification diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt index 9dfb94a..a8b0615 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt @@ -39,7 +39,7 @@ class MainActivity : AppCompatActivity() { } // Update main list based on viewModel (& its datasource/livedata) - val noEntriesText: View = findViewById(R.id.main_no_subscriptions_text) + val noEntries: View = findViewById(R.id.main_no_subscriptions) val adapter = SubscriptionsAdapter { subscription -> onSubscriptionItemClick(subscription) } val mainList: RecyclerView = findViewById(R.id.main_subscriptions_list) mainList.adapter = adapter @@ -49,10 +49,10 @@ class MainActivity : AppCompatActivity() { adapter.submitList(it as MutableList) if (it.isEmpty()) { mainList.visibility = View.GONE - noEntriesText.visibility = View.VISIBLE + noEntries.visibility = View.VISIBLE } else { mainList.visibility = View.VISIBLE - noEntriesText.visibility = View.GONE + noEntries.visibility = View.GONE } } } @@ -118,6 +118,6 @@ class MainActivity : AppCompatActivity() { const val EXTRA_SUBSCRIPTION_ID = "subscriptionId" const val EXTRA_SUBSCRIPTION_BASE_URL = "subscriptionBaseUrl" const val EXTRA_SUBSCRIPTION_TOPIC = "subscriptionTopic" - const val REQUEST_CODE_DELETE_SUBSCRIPTION = 1; + const val REQUEST_CODE_DELETE_SUBSCRIPTION = 1 } } diff --git a/app/src/main/res/drawable/ic_sms_black_48dp.xml b/app/src/main/res/drawable/ic_sms_black_48dp.xml new file mode 100644 index 0000000..0012ec5 --- /dev/null +++ b/app/src/main/res/drawable/ic_sms_black_48dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 622a9d8..933b54e 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -1,7 +1,7 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/sms_black_24dp.svg b/assets/sms_black_24dp.svg new file mode 100644 index 0000000..325be45 --- /dev/null +++ b/assets/sms_black_24dp.svg @@ -0,0 +1 @@ + \ No newline at end of file