Always show UP subscriptions at the bottom

This commit is contained in:
Philipp Heckel 2022-01-01 17:09:00 +01:00
parent d10344549f
commit bf419dda23
4 changed files with 9 additions and 8 deletions

View file

@ -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<List<SubscriptionWithMetadata>>
@ -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<SubscriptionWithMetadata>

View file

@ -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

View file

@ -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

View file

@ -165,7 +165,7 @@
<string name="settings_unified_push_header">UnifiedPush</string>
<string name="settings_unified_push_header_summary">Allows other apps to use ntfy as a message distributor. Find out more at unifiedpush.org.</string>
<string name="settings_unified_push_enabled_key">UnifiedPushEnabled</string>
<string name="settings_unified_push_enabled_title">Enable distributor</string>
<string name="settings_unified_push_enabled_title">Allow distributor use</string>
<string name="settings_unified_push_enabled_summary_on">Apps can use ntfy as distributor</string>
<string name="settings_unified_push_enabled_summary_off">Apps cannot use ntfy as distributor</string>
<string name="settings_unified_push_base_url_key">UnifiedPushBaseURL</string>