mirror of
https://github.com/binwiederhier/ntfy-android.git
synced 2024-06-28 11:10:44 +12:00
Tiny changes
This commit is contained in:
parent
2bc87013d5
commit
bec263d1c8
|
@ -7,6 +7,10 @@ import io.heckel.ntfy.data.Subscription
|
||||||
import io.heckel.ntfy.up.Distributor
|
import io.heckel.ntfy.up.Distributor
|
||||||
import io.heckel.ntfy.util.safeLet
|
import io.heckel.ntfy.util.safeLet
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The notification dispatcher figures out what to do with a notification.
|
||||||
|
* It may display a notification, send out a broadcast, or forward via UnifiedPush.
|
||||||
|
*/
|
||||||
class NotificationDispatcher(val context: Context, val repository: Repository) {
|
class NotificationDispatcher(val context: Context, val repository: Repository) {
|
||||||
private val notifier = NotificationService(context)
|
private val notifier = NotificationService(context)
|
||||||
private val broadcaster = BroadcastService(context)
|
private val broadcaster = BroadcastService(context)
|
||||||
|
@ -48,8 +52,4 @@ class NotificationDispatcher(val context: Context, val repository: Repository) {
|
||||||
}
|
}
|
||||||
return subscription.mutedUntil == 1L || (subscription.mutedUntil > 1L && subscription.mutedUntil > System.currentTimeMillis()/1000)
|
return subscription.mutedUntil == 1L || (subscription.mutedUntil > 1L && subscription.mutedUntil > System.currentTimeMillis()/1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAG = "NtfyNotificationDispatcher"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
private val repository by lazy { (application as Application).repository }
|
private val repository by lazy { (application as Application).repository }
|
||||||
private val api = ApiService()
|
private val api = ApiService()
|
||||||
private val messenger = FirebaseMessenger()
|
private val messenger = FirebaseMessenger()
|
||||||
private var serviceManager: SubscriberServiceManager? = null // Context-dependent
|
|
||||||
private var notifier: NotificationService? = null // Context-dependent
|
private var notifier: NotificationService? = null // Context-dependent
|
||||||
private var appBaseUrl: String? = null // Context-dependent
|
private var appBaseUrl: String? = null // Context-dependent
|
||||||
|
|
||||||
|
@ -69,7 +68,6 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
Log.d(MainActivity.TAG, "Create $this")
|
Log.d(MainActivity.TAG, "Create $this")
|
||||||
|
|
||||||
// Dependencies that depend on Context
|
// Dependencies that depend on Context
|
||||||
serviceManager = SubscriberServiceManager(this)
|
|
||||||
notifier = NotificationService(this)
|
notifier = NotificationService(this)
|
||||||
appBaseUrl = getString(R.string.app_base_url)
|
appBaseUrl = getString(R.string.app_base_url)
|
||||||
|
|
||||||
|
@ -146,7 +144,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
|
|
||||||
// React to changes in fast delivery setting
|
// React to changes in fast delivery setting
|
||||||
repository.getSubscriptionIdsWithInstantStatusLiveData().observe(this) {
|
repository.getSubscriptionIdsWithInstantStatusLiveData().observe(this) {
|
||||||
serviceManager?.refresh()
|
SubscriberServiceManager.refresh(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark this subscription as "open" so we don't receive notifications for it
|
// Mark this subscription as "open" so we don't receive notifications for it
|
||||||
|
|
|
@ -54,7 +54,6 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
private var actionMode: ActionMode? = null
|
private var actionMode: ActionMode? = null
|
||||||
private var workManager: WorkManager? = null // Context-dependent
|
private var workManager: WorkManager? = null // Context-dependent
|
||||||
private var dispatcher: NotificationDispatcher? = null // Context-dependent
|
private var dispatcher: NotificationDispatcher? = null // Context-dependent
|
||||||
private var serviceManager: SubscriberServiceManager? = null // Context-dependent
|
|
||||||
private var appBaseUrl: String? = null // Context-dependent
|
private var appBaseUrl: String? = null // Context-dependent
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -66,7 +65,6 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
// Dependencies that depend on Context
|
// Dependencies that depend on Context
|
||||||
workManager = WorkManager.getInstance(this)
|
workManager = WorkManager.getInstance(this)
|
||||||
dispatcher = NotificationDispatcher(this, repository)
|
dispatcher = NotificationDispatcher(this, repository)
|
||||||
serviceManager = SubscriberServiceManager(this)
|
|
||||||
appBaseUrl = getString(R.string.app_base_url)
|
appBaseUrl = getString(R.string.app_base_url)
|
||||||
|
|
||||||
// Action bar
|
// Action bar
|
||||||
|
@ -107,7 +105,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
|
|
||||||
// React to changes in instant delivery setting
|
// React to changes in instant delivery setting
|
||||||
viewModel.listIdsWithInstantStatus().observe(this) {
|
viewModel.listIdsWithInstantStatus().observe(this) {
|
||||||
serviceManager?.refresh()
|
SubscriberServiceManager.refresh(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create notification channels right away, so we can configure them immediately after installing the app
|
// Create notification channels right away, so we can configure them immediately after installing the app
|
||||||
|
|
Loading…
Reference in a new issue