-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathBlockingManager.kt
More file actions
45 lines (34 loc) · 1.73 KB
/
Copy pathBlockingManager.kt
File metadata and controls
45 lines (34 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package dev.octoshrimpy.quik.blocking
import dev.octoshrimpy.quik.util.Preferences
import io.reactivex.Completable
import io.reactivex.Single
import javax.inject.Inject
import javax.inject.Singleton
/**
* Delegates requests to the active blocking client
*/
@Singleton
class BlockingManager @Inject constructor(
private val prefs: Preferences,
private val callBlockerBlockingClient: CallBlockerBlockingClient,
private val callControlBlockingClient: CallControlBlockingClient,
private val qksmsBlockingClient: QksmsBlockingClient,
private val shouldIAnswerBlockingClient: ShouldIAnswerBlockingClient,
private val spamBlockerBlockingClient: SpamBlockerBlockingClient
) : BlockingClient {
private val client: BlockingClient
get() = when (prefs.blockingManager.get()) {
Preferences.BLOCKING_MANAGER_CB -> callBlockerBlockingClient
Preferences.BLOCKING_MANAGER_SIA -> shouldIAnswerBlockingClient
Preferences.BLOCKING_MANAGER_CC -> callControlBlockingClient
Preferences.BLOCKING_MANAGER_SB -> spamBlockerBlockingClient
else -> qksmsBlockingClient
}
override fun isAvailable(): Boolean = client.isAvailable()
override fun getClientCapability(): BlockingClient.Capability = client.getClientCapability()
override fun shouldBlock(address: String): Single<BlockingClient.Action> = client.shouldBlock(address)
override fun isBlacklisted(address: String): Single<BlockingClient.Action> = client.isBlacklisted(address)
override fun block(addresses: List<String>): Completable = client.block(addresses)
override fun unblock(addresses: List<String>): Completable = client.unblock(addresses)
override fun openSettings() = client.openSettings()
}