Loading app/src/main/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,13 @@ <!-- Subscriber foreground service for hosts other than ntfy.sh --> <service android:name=".msg.SubscriberService" /> <!-- Subscriber service restart on reboot --> <receiver android:enabled="true" android:name=".msg.SubscriberService$StartReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> <!-- Firebase messaging --> <service android:name=".msg.FirebaseService" Loading app/src/main/java/io/heckel/ntfy/data/Database.kt +3 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ interface SubscriptionDao { @Insert fun add(subscription: Subscription) @Update fun update(subscription: Subscription) @Query("DELETE FROM subscription WHERE id = :subscriptionId") fun remove(subscriptionId: Long) } Loading app/src/main/java/io/heckel/ntfy/data/Repository.kt +14 −2 Original line number Diff line number Diff line Loading @@ -19,17 +19,23 @@ class Repository(private val subscriptionDao: SubscriptionDao, private val notif .map { list -> toSubscriptionList(list) } } fun getSubscriptionIdsLiveData(): LiveData<Set<Long>> { fun getSubscriptionIdsWithInstantStatusLiveData(): LiveData<Set<Pair<Long, Boolean>>> { return subscriptionDao .listFlow() .asLiveData() .map { list -> list.map { it.id }.toSet() } .map { list -> list.map { Pair(it.id, it.instant) }.toSet() } } fun getSubscriptions(): List<Subscription> { return toSubscriptionList(subscriptionDao.list()) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun getSubscription(subscriptionId: Long): Subscription? { return toSubscription(subscriptionDao.get(subscriptionId)) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun getSubscription(baseUrl: String, topic: String): Subscription? { Loading @@ -42,6 +48,12 @@ class Repository(private val subscriptionDao: SubscriptionDao, private val notif subscriptionDao.add(subscription) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun updateSubscription(subscription: Subscription) { subscriptionDao.update(subscription) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun removeSubscription(subscriptionId: Long) { Loading app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +2 −0 Original line number Diff line number Diff line Loading @@ -79,10 +79,12 @@ class ApiService { } } } catch (e: Exception) { Log.e(TAG, "Connection to $url failed (1): ${e.message}", e) fail(e) } } override fun onFailure(call: Call, e: IOException) { Log.e(TAG, "Connection to $url failed (2): ${e.message}", e) fail(e) } }) Loading app/src/main/java/io/heckel/ntfy/msg/FirebaseService.kt +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class FirebaseService : FirebaseMessagingService() { Log.d(TAG, "Discarding unexpected message: from=${remoteMessage.from}, data=${data}") return } Log.d(TAG, "Received notification: from=${remoteMessage.from}, data=${data}") CoroutineScope(job).launch { val baseUrl = getString(R.string.app_base_url) // Everything from Firebase comes from main service URL! Loading Loading
app/src/main/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,13 @@ <!-- Subscriber foreground service for hosts other than ntfy.sh --> <service android:name=".msg.SubscriberService" /> <!-- Subscriber service restart on reboot --> <receiver android:enabled="true" android:name=".msg.SubscriberService$StartReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> <!-- Firebase messaging --> <service android:name=".msg.FirebaseService" Loading
app/src/main/java/io/heckel/ntfy/data/Database.kt +3 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ interface SubscriptionDao { @Insert fun add(subscription: Subscription) @Update fun update(subscription: Subscription) @Query("DELETE FROM subscription WHERE id = :subscriptionId") fun remove(subscriptionId: Long) } Loading
app/src/main/java/io/heckel/ntfy/data/Repository.kt +14 −2 Original line number Diff line number Diff line Loading @@ -19,17 +19,23 @@ class Repository(private val subscriptionDao: SubscriptionDao, private val notif .map { list -> toSubscriptionList(list) } } fun getSubscriptionIdsLiveData(): LiveData<Set<Long>> { fun getSubscriptionIdsWithInstantStatusLiveData(): LiveData<Set<Pair<Long, Boolean>>> { return subscriptionDao .listFlow() .asLiveData() .map { list -> list.map { it.id }.toSet() } .map { list -> list.map { Pair(it.id, it.instant) }.toSet() } } fun getSubscriptions(): List<Subscription> { return toSubscriptionList(subscriptionDao.list()) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun getSubscription(subscriptionId: Long): Subscription? { return toSubscription(subscriptionDao.get(subscriptionId)) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun getSubscription(baseUrl: String, topic: String): Subscription? { Loading @@ -42,6 +48,12 @@ class Repository(private val subscriptionDao: SubscriptionDao, private val notif subscriptionDao.add(subscription) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun updateSubscription(subscription: Subscription) { subscriptionDao.update(subscription) } @Suppress("RedundantSuspendModifier") @WorkerThread suspend fun removeSubscription(subscriptionId: Long) { Loading
app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +2 −0 Original line number Diff line number Diff line Loading @@ -79,10 +79,12 @@ class ApiService { } } } catch (e: Exception) { Log.e(TAG, "Connection to $url failed (1): ${e.message}", e) fail(e) } } override fun onFailure(call: Call, e: IOException) { Log.e(TAG, "Connection to $url failed (2): ${e.message}", e) fail(e) } }) Loading
app/src/main/java/io/heckel/ntfy/msg/FirebaseService.kt +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class FirebaseService : FirebaseMessagingService() { Log.d(TAG, "Discarding unexpected message: from=${remoteMessage.from}, data=${data}") return } Log.d(TAG, "Received notification: from=${remoteMessage.from}, data=${data}") CoroutineScope(job).launch { val baseUrl = getString(R.string.app_base_url) // Everything from Firebase comes from main service URL! Loading