From bf419dda23b6ebac06372819d03aeb254d24fe01 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Sat, 1 Jan 2022 17:09:00 +0100 Subject: [PATCH] Always show UP subscriptions at the bottom --- app/src/main/java/io/heckel/ntfy/data/Database.kt | 4 ++-- app/src/main/java/io/heckel/ntfy/data/Repository.kt | 1 - app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt | 10 ++++++---- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) 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 8fc2325..578663f 100644 --- a/app/src/main/java/io/heckel/ntfy/data/Database.kt +++ b/app/src/main/java/io/heckel/ntfy/data/Database.kt @@ -129,7 +129,7 @@ interface SubscriptionDao { FROM Subscription AS s LEFT JOIN Notification AS n ON s.id=n.subscriptionId AND n.deleted != 1 GROUP BY s.id - ORDER BY MAX(n.timestamp) DESC + ORDER BY s.upAppId ASC, MAX(n.timestamp) DESC """) fun listFlow(): Flow> @@ -142,7 +142,7 @@ interface SubscriptionDao { FROM Subscription AS s LEFT JOIN Notification AS n ON s.id=n.subscriptionId AND n.deleted != 1 GROUP BY s.id - ORDER BY MAX(n.timestamp) DESC + ORDER BY s.upAppId ASC, MAX(n.timestamp) DESC """) fun list(): List diff --git a/app/src/main/java/io/heckel/ntfy/data/Repository.kt b/app/src/main/java/io/heckel/ntfy/data/Repository.kt index 0907ca4..bf4971d 100644 --- a/app/src/main/java/io/heckel/ntfy/data/Repository.kt +++ b/app/src/main/java/io/heckel/ntfy/data/Repository.kt @@ -4,7 +4,6 @@ import android.content.SharedPreferences import android.util.Log import androidx.annotation.WorkerThread import androidx.lifecycle.* -import androidx.preference.PreferenceManager import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.atomic.AtomicLong diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt b/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt index 6a361ed..72c926e 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt @@ -56,7 +56,8 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs fun bind(subscription: Subscription) { this.subscription = subscription - var statusMessage = if (subscription.upAppId != null) { + val isUnifiedPush = subscription.upAppId != null + var statusMessage = if (isUnifiedPush) { context.getString(R.string.main_item_status_unified_push, subscription.upAppId) } else if (subscription.totalCount == 1) { context.getString(R.string.main_item_status_text_one, subscription.totalCount) @@ -80,15 +81,16 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs dateStr } val globalMutedUntil = repository.getGlobalMutedUntil() - val showMutedForeverIcon = (subscription.mutedUntil == 1L || globalMutedUntil == 1L) && subscription.upAppId == null - val showMutedUntilIcon = !showMutedForeverIcon && (subscription.mutedUntil > 1L || globalMutedUntil > 1L) && subscription.upAppId == null + val showMutedForeverIcon = (subscription.mutedUntil == 1L || globalMutedUntil == 1L) && !isUnifiedPush + val showMutedUntilIcon = !showMutedForeverIcon && (subscription.mutedUntil > 1L || globalMutedUntil > 1L) && !isUnifiedPush nameView.text = topicShortUrl(subscription.baseUrl, subscription.topic) statusView.text = statusMessage dateView.text = dateText + dateView.visibility = if (isUnifiedPush) View.GONE else View.VISIBLE notificationDisabledUntilImageView.visibility = if (showMutedUntilIcon) View.VISIBLE else View.GONE notificationDisabledForeverImageView.visibility = if (showMutedForeverIcon) View.VISIBLE else View.GONE instantImageView.visibility = if (subscription.instant) View.VISIBLE else View.GONE - if (subscription.upAppId != null || subscription.newCount == 0) { + if (isUnifiedPush || subscription.newCount == 0) { newItemsView.visibility = View.GONE } else { newItemsView.visibility = View.VISIBLE diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8260b34..1767b78 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -165,7 +165,7 @@ UnifiedPush Allows other apps to use ntfy as a message distributor. Find out more at unifiedpush.org. UnifiedPushEnabled - Enable distributor + Allow distributor use Apps can use ntfy as distributor Apps cannot use ntfy as distributor UnifiedPushBaseURL