forked from upstream-mirrors/quik
Add ability to launch settings of blocking manager
This commit is contained in:
@@ -34,4 +34,6 @@ class BlockingManager @Inject constructor(
|
||||
|
||||
override fun unblock(addresses: List<String>): Completable = client.unblock(addresses)
|
||||
|
||||
override fun openSettings() = client.openSettings()
|
||||
|
||||
}
|
||||
|
||||
@@ -66,4 +66,8 @@ class CallControlBlockingClient @Inject constructor(
|
||||
CallControl.openBlockedList(context, address)
|
||||
}
|
||||
|
||||
override fun openSettings() {
|
||||
CallControl.openBlockedList(context)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
package com.moez.QKSMS.blocking
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.BlockedNumberContract
|
||||
import android.telecom.TelecomManager
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.moez.QKSMS.extensions.anyOf
|
||||
@@ -89,4 +91,16 @@ class QkBlockingClient @Inject constructor(private val context: Context) : Block
|
||||
}
|
||||
}
|
||||
|
||||
override fun openSettings() = when {
|
||||
Build.VERSION.SDK_INT >= 24 -> {
|
||||
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
||||
val intent = telecomManager.createManageBlockedNumbersIntent()
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
else -> {} // TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,16 +54,17 @@ class ShouldIAnswerBlockingClient @Inject constructor(
|
||||
return Binder(context, address).isBlocked()
|
||||
}
|
||||
|
||||
override fun block(addresses: List<String>): Completable = Completable.fromCallable { showSia() }
|
||||
override fun block(addresses: List<String>): Completable = Completable.fromCallable { openSettings() }
|
||||
|
||||
override fun unblock(addresses: List<String>): Completable = Completable.fromCallable { showSia() }
|
||||
override fun unblock(addresses: List<String>): Completable = Completable.fromCallable { openSettings() }
|
||||
|
||||
private fun showSia() {
|
||||
override fun openSettings() {
|
||||
val pm = context.packageManager
|
||||
pm.getLaunchIntentForPackage("org.mistergroup.shouldianswer")
|
||||
val intent = pm.getLaunchIntentForPackage("org.mistergroup.shouldianswer")
|
||||
?: pm.getLaunchIntentForPackage("org.mistergroup.shouldianswerpersonal")
|
||||
?: pm.getLaunchIntentForPackage("org.mistergroup.muzutozvednout")
|
||||
?.run(context::startActivity)
|
||||
|
||||
intent?.run(context::startActivity)
|
||||
}
|
||||
|
||||
private class Binder(
|
||||
|
||||
Reference in New Issue
Block a user