mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
#1304 - Create blocking client for built-in android blocking
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package com.moez.QKSMS.blocking
|
||||
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Single
|
||||
|
||||
interface BlockingClient {
|
||||
@@ -25,6 +26,28 @@ interface BlockingClient {
|
||||
/**
|
||||
* Return a Single<Boolean> which emits whether or not the given [address] should be blocked
|
||||
*/
|
||||
fun shouldBlock(address: String): Single<Boolean>
|
||||
fun isBlocked(address: String): Single<Boolean>
|
||||
|
||||
/**
|
||||
* Returns true if the client is capable of blocking the address in the manager without any
|
||||
* further user input
|
||||
*/
|
||||
fun canBlock(): Boolean = false
|
||||
|
||||
/**
|
||||
* Blocks the number or opens the manager
|
||||
*/
|
||||
fun block(address: String): Completable
|
||||
|
||||
/**
|
||||
* Returns true if the client is capable of unblocking the address in the manager without any
|
||||
* further user input
|
||||
*/
|
||||
fun canUnblock(): Boolean = false
|
||||
|
||||
/**
|
||||
* Unblocks the number or opens the manager
|
||||
*/
|
||||
fun unblock(address: String): Completable
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class ReceiveMms @Inject constructor(
|
||||
// to check if it should be blocked after we've pulled it into realm. If it
|
||||
// turns out that it should be dropped, then delete it
|
||||
// TODO Don't store blocked messages in the first place
|
||||
val shouldBlock = blockingClient.shouldBlock(message.address).blockingGet()
|
||||
val shouldBlock = blockingClient.isBlocked(message.address).blockingGet()
|
||||
val shouldDrop = prefs.drop.get()
|
||||
Timber.v("block=$shouldBlock, drop=$shouldDrop")
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class ReceiveSms @Inject constructor(
|
||||
// Don't continue if the sender is blocked
|
||||
val messages = it.messages
|
||||
val address = messages[0].displayOriginatingAddress
|
||||
val shouldBlock = blockingClient.shouldBlock(address).blockingGet()
|
||||
val shouldBlock = blockingClient.isBlocked(address).blockingGet()
|
||||
val shouldDrop = prefs.drop.get()
|
||||
Timber.v("block=$shouldBlock, drop=$shouldDrop")
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.moez.QKSMS.model
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class BlockedNumber(
|
||||
@PrimaryKey var id: Long = 0,
|
||||
|
||||
var address: String = ""
|
||||
) : RealmObject()
|
||||
Reference in New Issue
Block a user