forked from upstream-mirrors/quik
Add UI for toggling Call Control
This commit is contained in:
@@ -76,6 +76,7 @@ class Preferences @Inject constructor(private val rxPrefs: RxSharedPreferences)
|
||||
val black = rxPrefs.getBoolean("black", false)
|
||||
val systemFont = rxPrefs.getBoolean("systemFont", false)
|
||||
val textSize = rxPrefs.getInteger("textSize", TEXT_SIZE_NORMAL)
|
||||
val callControl = rxPrefs.getBoolean("callControl", false)
|
||||
val sia = rxPrefs.getBoolean("sia", false)
|
||||
val notifAction1 = rxPrefs.getInteger("notifAction1", NOTIFICATION_ACTION_READ)
|
||||
val notifAction2 = rxPrefs.getInteger("notifAction2", NOTIFICATION_ACTION_REPLY)
|
||||
|
||||
@@ -180,6 +180,15 @@ class Navigator @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the Play Store and display the Call Control listing
|
||||
*/
|
||||
fun showCallControl() {
|
||||
val url = "https://play.google.com/store/apps/details?id=com.flexaspect.android.everycallcontrol"
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the Play Store and display the Should I Answer? listing
|
||||
*/
|
||||
|
||||
@@ -37,6 +37,7 @@ class BlockedActivity : QkThemedActivity(), BlockedView {
|
||||
@Inject lateinit var blockedAdapter: BlockedAdapter
|
||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
||||
override val ccClickedIntent by lazy { callControl.clicks() }
|
||||
override val siaClickedIntent by lazy { shouldIAnswer.clicks() }
|
||||
override val unblockIntent by lazy { blockedAdapter.unblock }
|
||||
override val confirmUnblockIntent: Subject<Long> = PublishSubject.create()
|
||||
@@ -56,6 +57,7 @@ class BlockedActivity : QkThemedActivity(), BlockedView {
|
||||
}
|
||||
|
||||
override fun render(state: BlockedState) {
|
||||
callControl.checkbox.isChecked = state.ccEnabled
|
||||
shouldIAnswer.checkbox.isChecked = state.siaEnabled
|
||||
|
||||
blockedAdapter.updateData(state.data)
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.moez.QKSMS.model.Conversation
|
||||
import io.realm.RealmResults
|
||||
|
||||
data class BlockedState(
|
||||
val ccEnabled: Boolean = false,
|
||||
val siaEnabled: Boolean = false,
|
||||
val data: RealmResults<Conversation>? = null
|
||||
)
|
||||
@@ -23,6 +23,7 @@ import io.reactivex.Observable
|
||||
|
||||
interface BlockedView : QkView<BlockedState> {
|
||||
|
||||
val ccClickedIntent: Observable<*>
|
||||
val siaClickedIntent: Observable<*>
|
||||
val unblockIntent: Observable<Long>
|
||||
val confirmUnblockIntent: Observable<Long>
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.moez.QKSMS.util.tryOrNull
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockedViewModel @Inject constructor(
|
||||
@@ -44,6 +43,9 @@ class BlockedViewModel @Inject constructor(
|
||||
init {
|
||||
newState { copy(data = conversationRepo.getBlockedConversations()) }
|
||||
|
||||
disposables += prefs.callControl.asObservable()
|
||||
.subscribe { enabled -> newState { copy(ccEnabled = enabled) } }
|
||||
|
||||
disposables += prefs.sia.asObservable()
|
||||
.subscribe { enabled -> newState { copy(siaEnabled = enabled) } }
|
||||
}
|
||||
@@ -51,6 +53,20 @@ class BlockedViewModel @Inject constructor(
|
||||
override fun bindView(view: BlockedView) {
|
||||
super.bindView(view)
|
||||
|
||||
view.ccClickedIntent
|
||||
.map { tryOrNull(false) { context.packageManager.getApplicationInfo("com.flexaspect.android.everycallcontrol", 0).enabled } ?: false }
|
||||
.map { installed ->
|
||||
if (!installed) {
|
||||
navigator.showCallControl()
|
||||
}
|
||||
|
||||
val enabled = prefs.callControl.get()
|
||||
analytics.track("Clicked Call Control", Pair("enable", !enabled), Pair("installed", installed))
|
||||
installed && !enabled
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe(prefs.callControl::set)
|
||||
|
||||
view.siaClickedIntent
|
||||
.map {
|
||||
tryOrNull(false) { context.packageManager.getApplicationInfo("org.mistergroup.shouldianswer", 0).enabled }
|
||||
@@ -58,13 +74,17 @@ class BlockedViewModel @Inject constructor(
|
||||
?: tryOrNull(false) { context.packageManager.getApplicationInfo("org.mistergroup.muzutozvednout", 0).enabled }
|
||||
?: false
|
||||
}
|
||||
.doOnNext { installed -> if (!installed) navigator.showSia() }
|
||||
.withLatestFrom(prefs.sia.asObservable()) { installed, enabled ->
|
||||
.map { installed ->
|
||||
if (!installed) {
|
||||
navigator.showSia()
|
||||
}
|
||||
|
||||
val enabled = prefs.sia.get()
|
||||
analytics.track("Clicked SIA", Pair("enable", !enabled), Pair("installed", installed))
|
||||
installed && !enabled
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { shouldEnable -> prefs.sia.set(shouldEnable) }
|
||||
.subscribe(prefs.sia::set)
|
||||
|
||||
// Show confirm unblock conversation dialog
|
||||
view.unblockIntent
|
||||
|
||||
@@ -54,6 +54,17 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:id="@+id/callControl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
app:summary="@string/settings_call_control_summary"
|
||||
app:title="@string/settings_call_control_title"
|
||||
app:widget="@layout/settings_switch_widget" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:id="@+id/shouldIAnswer"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -222,6 +222,8 @@
|
||||
<string name="settings_qkreply_tap_dismiss_summary">Tap outside of the popup to close it</string>
|
||||
<string name="settings_blocking_title">Blocking</string>
|
||||
<!-- Do not translate -->
|
||||
<string name="settings_call_control_title">Call Control</string>
|
||||
<string name="settings_call_control_summary">Automatically filter your calls and messages in one convenient place! Community IQ™ allows you to prevent unwanted messages from community known spammers</string>
|
||||
<string name="settings_should_i_answer_title">Should I Answer?</string>
|
||||
<string name="settings_should_i_answer_summary">Automatically filter messages from unsolicited numbers by using the \"Should I Answer\" app</string>
|
||||
<string name="settings_delayed_title">Delayed sending</string>
|
||||
|
||||
Reference in New Issue
Block a user