Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bec263d1 authored by Philipp Heckel's avatar Philipp Heckel
Browse files

Tiny changes

parent 2bc87013
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -7,6 +7,10 @@ import io.heckel.ntfy.data.Subscription
import io.heckel.ntfy.up.Distributor
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) {
    private val notifier = NotificationService(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)
    }

    companion object {
        private const val TAG = "NtfyNotificationDispatcher"
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
    private val repository by lazy { (application as Application).repository }
    private val api = ApiService()
    private val messenger = FirebaseMessenger()
    private var serviceManager: SubscriberServiceManager? = null // Context-dependent
    private var notifier: NotificationService? = 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")

        // Dependencies that depend on Context
        serviceManager = SubscriberServiceManager(this)
        notifier = NotificationService(this)
        appBaseUrl = getString(R.string.app_base_url)

@@ -146,7 +144,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra

        // React to changes in fast delivery setting
        repository.getSubscriptionIdsWithInstantStatusLiveData().observe(this) {
            serviceManager?.refresh()
            SubscriberServiceManager.refresh(this)
        }

        // Mark this subscription as "open" so we don't receive notifications for it
+1 −3
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
    private var actionMode: ActionMode? = null
    private var workManager: WorkManager? = null // Context-dependent
    private var dispatcher: NotificationDispatcher? = null // Context-dependent
    private var serviceManager: SubscriberServiceManager? = null // Context-dependent
    private var appBaseUrl: String? = null // Context-dependent

    override fun onCreate(savedInstanceState: Bundle?) {
@@ -66,7 +65,6 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
        // Dependencies that depend on Context
        workManager = WorkManager.getInstance(this)
        dispatcher = NotificationDispatcher(this, repository)
        serviceManager = SubscriberServiceManager(this)
        appBaseUrl = getString(R.string.app_base_url)

        // Action bar
@@ -107,7 +105,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc

        // React to changes in instant delivery setting
        viewModel.listIdsWithInstantStatus().observe(this) {
            serviceManager?.refresh()
            SubscriberServiceManager.refresh(this)
        }

        // Create notification channels right away, so we can configure them immediately after installing the app