Hide instant delivery icons and text for F-Droid
This commit is contained in:
parent
ddb83cbea9
commit
ca217d8275
6 changed files with 46 additions and 22 deletions
|
@ -4,7 +4,10 @@ import android.app.*
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.*
|
import android.os.Build
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.os.PowerManager
|
||||||
|
import android.os.SystemClock
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -17,7 +20,9 @@ import io.heckel.ntfy.msg.ApiService
|
||||||
import io.heckel.ntfy.msg.NotificationDispatcher
|
import io.heckel.ntfy.msg.NotificationDispatcher
|
||||||
import io.heckel.ntfy.ui.MainActivity
|
import io.heckel.ntfy.ui.MainActivity
|
||||||
import io.heckel.ntfy.util.topicUrl
|
import io.heckel.ntfy.util.topicUrl
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +85,11 @@ class SubscriberService : Service() {
|
||||||
Log.d(TAG, "Subscriber service has been created")
|
Log.d(TAG, "Subscriber service has been created")
|
||||||
|
|
||||||
val title = getString(R.string.channel_subscriber_notification_title)
|
val title = getString(R.string.channel_subscriber_notification_title)
|
||||||
val text = getString(R.string.channel_subscriber_notification_text)
|
val text = if (BuildConfig.FIREBASE_AVAILABLE) {
|
||||||
|
getString(R.string.channel_subscriber_notification_instant_text)
|
||||||
|
} else {
|
||||||
|
getString(R.string.channel_subscriber_notification_noinstant_text)
|
||||||
|
}
|
||||||
notificationManager = createNotificationChannel()
|
notificationManager = createNotificationChannel()
|
||||||
serviceNotification = createNotification(title, text)
|
serviceNotification = createNotification(title, text)
|
||||||
|
|
||||||
|
@ -184,12 +193,22 @@ class SubscriberService : Service() {
|
||||||
if (connections.size > 0) {
|
if (connections.size > 0) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
val title = getString(R.string.channel_subscriber_notification_title)
|
val title = getString(R.string.channel_subscriber_notification_title)
|
||||||
val text = when (instantSubscriptions.size) {
|
val text = if (BuildConfig.FIREBASE_AVAILABLE) {
|
||||||
1 -> getString(R.string.channel_subscriber_notification_text_one)
|
when (instantSubscriptions.size) {
|
||||||
2 -> getString(R.string.channel_subscriber_notification_text_two)
|
1 -> getString(R.string.channel_subscriber_notification_instant_text_one)
|
||||||
3 -> getString(R.string.channel_subscriber_notification_text_three)
|
2 -> getString(R.string.channel_subscriber_notification_instant_text_two)
|
||||||
4 -> getString(R.string.channel_subscriber_notification_text_four)
|
3 -> getString(R.string.channel_subscriber_notification_instant_text_three)
|
||||||
else -> getString(R.string.channel_subscriber_notification_text_more, instantSubscriptions.size)
|
4 -> getString(R.string.channel_subscriber_notification_instant_text_four)
|
||||||
|
else -> getString(R.string.channel_subscriber_notification_instant_text_more, instantSubscriptions.size)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
when (instantSubscriptions.size) {
|
||||||
|
1 -> getString(R.string.channel_subscriber_notification_noinstant_text_one)
|
||||||
|
2 -> getString(R.string.channel_subscriber_notification_noinstant_text_two)
|
||||||
|
3 -> getString(R.string.channel_subscriber_notification_noinstant_text_three)
|
||||||
|
4 -> getString(R.string.channel_subscriber_notification_noinstant_text_four)
|
||||||
|
else -> getString(R.string.channel_subscriber_notification_noinstant_text_more, instantSubscriptions.size)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
serviceNotification = createNotification(title, text)
|
serviceNotification = createNotification(title, text)
|
||||||
notificationManager?.notify(NOTIFICATION_SERVICE_ID, serviceNotification)
|
notificationManager?.notify(NOTIFICATION_SERVICE_ID, serviceNotification)
|
||||||
|
|
|
@ -23,14 +23,11 @@ import io.heckel.ntfy.BuildConfig
|
||||||
import io.heckel.ntfy.R
|
import io.heckel.ntfy.R
|
||||||
import io.heckel.ntfy.app.Application
|
import io.heckel.ntfy.app.Application
|
||||||
import io.heckel.ntfy.data.Notification
|
import io.heckel.ntfy.data.Notification
|
||||||
import io.heckel.ntfy.util.topicShortUrl
|
|
||||||
import io.heckel.ntfy.util.topicUrl
|
|
||||||
import io.heckel.ntfy.firebase.FirebaseMessenger
|
import io.heckel.ntfy.firebase.FirebaseMessenger
|
||||||
import io.heckel.ntfy.msg.ApiService
|
import io.heckel.ntfy.msg.ApiService
|
||||||
import io.heckel.ntfy.msg.NotificationService
|
import io.heckel.ntfy.msg.NotificationService
|
||||||
import io.heckel.ntfy.service.SubscriberServiceManager
|
import io.heckel.ntfy.service.SubscriberServiceManager
|
||||||
import io.heckel.ntfy.util.fadeStatusBarColor
|
import io.heckel.ntfy.util.*
|
||||||
import io.heckel.ntfy.util.formatDateShort
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
@ -401,7 +398,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
} else {
|
} else {
|
||||||
enableInstantItem?.isVisible = false
|
enableInstantItem?.isVisible = false
|
||||||
disableInstantItem?.isVisible = false
|
disableInstantItem?.isVisible = false
|
||||||
instantInfoItem?.isVisible = true
|
instantInfoItem?.isVisible = BuildConfig.FIREBASE_AVAILABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import io.heckel.ntfy.BuildConfig
|
||||||
import io.heckel.ntfy.R
|
import io.heckel.ntfy.R
|
||||||
import io.heckel.ntfy.data.ConnectionState
|
import io.heckel.ntfy.data.ConnectionState
|
||||||
import io.heckel.ntfy.data.Repository
|
import io.heckel.ntfy.data.Repository
|
||||||
|
@ -89,7 +90,7 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs
|
||||||
dateView.visibility = if (isUnifiedPush) View.GONE else View.VISIBLE
|
dateView.visibility = if (isUnifiedPush) View.GONE else View.VISIBLE
|
||||||
notificationDisabledUntilImageView.visibility = if (showMutedUntilIcon) View.VISIBLE else View.GONE
|
notificationDisabledUntilImageView.visibility = if (showMutedUntilIcon) View.VISIBLE else View.GONE
|
||||||
notificationDisabledForeverImageView.visibility = if (showMutedForeverIcon) View.VISIBLE else View.GONE
|
notificationDisabledForeverImageView.visibility = if (showMutedForeverIcon) View.VISIBLE else View.GONE
|
||||||
instantImageView.visibility = if (subscription.instant) View.VISIBLE else View.GONE
|
instantImageView.visibility = if (subscription.instant && BuildConfig.FIREBASE_AVAILABLE) View.VISIBLE else View.GONE
|
||||||
if (isUnifiedPush || subscription.newCount == 0) {
|
if (isUnifiedPush || subscription.newCount == 0) {
|
||||||
newItemsView.visibility = View.GONE
|
newItemsView.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -184,3 +184,4 @@ fun formatBytes(bytes: Long, decimals: Int = 1): String {
|
||||||
fun supportedImage(mimeType: String?): Boolean {
|
fun supportedImage(mimeType: String?): Boolean {
|
||||||
return listOf("image/jpeg", "image/png").contains(mimeType)
|
return listOf("image/jpeg", "image/png").contains(mimeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,18 @@
|
||||||
<string name="channel_notifications_max_name">Notifications (Max Priority)</string>
|
<string name="channel_notifications_max_name">Notifications (Max Priority)</string>
|
||||||
<string name="channel_subscriber_service_name">Subscription Service</string>
|
<string name="channel_subscriber_service_name">Subscription Service</string>
|
||||||
<string name="channel_subscriber_notification_title">Listening for incoming notifications</string>
|
<string name="channel_subscriber_notification_title">Listening for incoming notifications</string>
|
||||||
<string name="channel_subscriber_notification_text">You are subscribed to instant delivery topics</string>
|
<string name="channel_subscriber_notification_instant_text">You are subscribed to instant delivery topics</string>
|
||||||
<string name="channel_subscriber_notification_text_one">You are subscribed to one instant delivery topic</string>
|
<string name="channel_subscriber_notification_instant_text_one">You are subscribed to one instant delivery topic</string>
|
||||||
<string name="channel_subscriber_notification_text_two">You are subscribed to two instant delivery topics</string>
|
<string name="channel_subscriber_notification_instant_text_two">You are subscribed to two instant delivery topics</string>
|
||||||
<string name="channel_subscriber_notification_text_three">You are subscribed to three instant delivery topics</string>
|
<string name="channel_subscriber_notification_instant_text_three">You are subscribed to three instant delivery topics</string>
|
||||||
<string name="channel_subscriber_notification_text_four">You are subscribed to four instant delivery topics</string>
|
<string name="channel_subscriber_notification_instant_text_four">You are subscribed to four instant delivery topics</string>
|
||||||
<string name="channel_subscriber_notification_text_more">You are subscribed to %1$d instant delivery topics</string>
|
<string name="channel_subscriber_notification_instant_text_more">You are subscribed to %1$d instant delivery topics</string>
|
||||||
|
<string name="channel_subscriber_notification_noinstant_text">You are subscribed to topics</string>
|
||||||
|
<string name="channel_subscriber_notification_noinstant_text_one">You are subscribed to one topic</string>
|
||||||
|
<string name="channel_subscriber_notification_noinstant_text_two">You are subscribed to two topics</string>
|
||||||
|
<string name="channel_subscriber_notification_noinstant_text_three">You are subscribed to three topics</string>
|
||||||
|
<string name="channel_subscriber_notification_noinstant_text_four">You are subscribed to four topics</string>
|
||||||
|
<string name="channel_subscriber_notification_noinstant_text_more">You are subscribed to %1$d topics</string>
|
||||||
|
|
||||||
<!-- Common refresh toasts -->
|
<!-- Common refresh toasts -->
|
||||||
<string name="refresh_message_result">%1$d notification(s) received</string>
|
<string name="refresh_message_result">%1$d notification(s) received</string>
|
||||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath 'com.google.gms:google-services:4.3.10' // This is removed in the "fdroid" flavor
|
classpath 'com.google.gms:google-services:4.3.10' // This is removed in the "fdroid" flavor
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue