mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Add support for Call Blocker
This commit is contained in:
@@ -191,6 +191,15 @@ class Navigator @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the Play Store and display the Call Blocker listing
|
||||
*/
|
||||
fun installCallBlocker() {
|
||||
val url = "https://play.google.com/store/apps/details?id=com.cuiet.blockCalls"
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
startActivityExternal(intent)
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the Play Store and display the Call Control listing
|
||||
*/
|
||||
|
||||
+4
@@ -44,6 +44,9 @@ class BlockingManagerController : QkController<BlockingManagerView, BlockingMana
|
||||
override fun render(state: BlockingManagerState) {
|
||||
qksms.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_QKSMS
|
||||
|
||||
callBlocker.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_CB
|
||||
callBlocker.install.isVisible = !state.callBlockerInstalled
|
||||
|
||||
callControl.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_CC
|
||||
callControl.install.isVisible = !state.callControlInstalled
|
||||
|
||||
@@ -53,6 +56,7 @@ class BlockingManagerController : QkController<BlockingManagerView, BlockingMana
|
||||
|
||||
override fun activityResumed(): Observable<*> = activityResumedSubject
|
||||
override fun qksmsClicked(): Observable<*> = qksms.clicks()
|
||||
override fun callBlockerClicked(): Observable<*> = callBlocker.clicks()
|
||||
override fun callControlClicked(): Observable<*> = callControl.clicks()
|
||||
override fun siaClicked(): Observable<*> = shouldIAnswer.clicks()
|
||||
|
||||
|
||||
+26
@@ -3,6 +3,7 @@ package com.moez.QKSMS.feature.blocking.manager
|
||||
import android.content.Context
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.blocking.BlockingClient
|
||||
import com.moez.QKSMS.blocking.CallBlockerBlockingClient
|
||||
import com.moez.QKSMS.blocking.CallControlBlockingClient
|
||||
import com.moez.QKSMS.blocking.QksmsBlockingClient
|
||||
import com.moez.QKSMS.blocking.ShouldIAnswerBlockingClient
|
||||
@@ -21,6 +22,7 @@ import javax.inject.Inject
|
||||
|
||||
class BlockingManagerPresenter @Inject constructor(
|
||||
private val analytics: AnalyticsManager,
|
||||
private val callBlocker: CallBlockerBlockingClient,
|
||||
private val callControl: CallControlBlockingClient,
|
||||
private val context: Context,
|
||||
private val conversationRepo: ConversationRepository,
|
||||
@@ -30,6 +32,7 @@ class BlockingManagerPresenter @Inject constructor(
|
||||
private val shouldIAnswer: ShouldIAnswerBlockingClient
|
||||
) : QkPresenter<BlockingManagerView, BlockingManagerState>(BlockingManagerState(
|
||||
blockingManager = prefs.blockingManager.get(),
|
||||
callBlockerInstalled = callBlocker.isAvailable(),
|
||||
callControlInstalled = callControl.isAvailable(),
|
||||
siaInstalled = shouldIAnswer.isAvailable()
|
||||
)) {
|
||||
@@ -42,6 +45,12 @@ class BlockingManagerPresenter @Inject constructor(
|
||||
override fun bindIntents(view: BlockingManagerView) {
|
||||
super.bindIntents(view)
|
||||
|
||||
view.activityResumed()
|
||||
.map { callBlocker.isAvailable() }
|
||||
.distinctUntilChanged()
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { available -> newState { copy(callBlockerInstalled = available) } }
|
||||
|
||||
view.activityResumed()
|
||||
.map { callControl.isAvailable() }
|
||||
.distinctUntilChanged()
|
||||
@@ -64,6 +73,23 @@ class BlockingManagerPresenter @Inject constructor(
|
||||
prefs.blockingManager.set(Preferences.BLOCKING_MANAGER_QKSMS)
|
||||
}
|
||||
|
||||
view.callBlockerClicked()
|
||||
.filter {
|
||||
val installed = callBlocker.isAvailable()
|
||||
if (!installed) {
|
||||
analytics.track("Install Call Blocker")
|
||||
navigator.installCallBlocker()
|
||||
}
|
||||
|
||||
val enabled = prefs.blockingManager.get() == Preferences.BLOCKING_MANAGER_CB
|
||||
installed && !enabled
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe {
|
||||
analytics.setUserProperty("Blocking Manager", "Call Blocker")
|
||||
prefs.blockingManager.set(Preferences.BLOCKING_MANAGER_CB)
|
||||
}
|
||||
|
||||
view.callControlClicked()
|
||||
.filter {
|
||||
val installed = callControl.isAvailable()
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ package com.moez.QKSMS.feature.blocking.manager
|
||||
|
||||
data class BlockingManagerState(
|
||||
val blockingManager: Int = 0,
|
||||
val callBlockerInstalled: Boolean = false,
|
||||
val callControlInstalled: Boolean = false,
|
||||
val siaInstalled: Boolean = false
|
||||
)
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ interface BlockingManagerView : QkViewContract<BlockingManagerState> {
|
||||
|
||||
fun activityResumed(): Observable<*>
|
||||
fun qksmsClicked(): Observable<*>
|
||||
fun callBlockerClicked(): Observable<*>
|
||||
fun callControlClicked(): Observable<*>
|
||||
fun siaClicked(): Observable<*>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user