forked from upstream-mirrors/quik
Move option to edit blocking manager settings to selection screen
This commit is contained in:
@@ -32,6 +32,8 @@ class BlockingManager @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun isAvailable(): Boolean = client.isAvailable()
|
||||
|
||||
override fun isBlocked(address: String): Single<Boolean> = client.isBlocked(address)
|
||||
|
||||
override fun canBlock(): Boolean = client.canBlock()
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import androidx.core.database.getStringOrNull
|
||||
import com.callcontrol.datashare.CallControl
|
||||
import com.moez.QKSMS.common.util.extensions.isInstalled
|
||||
import com.moez.QKSMS.extensions.map
|
||||
import com.moez.QKSMS.util.tryOrNull
|
||||
import io.reactivex.Completable
|
||||
@@ -43,6 +44,8 @@ class CallControlBlockingClient @Inject constructor(
|
||||
val blockReason: String? = cursor.getStringOrNull(0)
|
||||
}
|
||||
|
||||
override fun isAvailable(): Boolean = context.isInstalled("com.flexaspect.android.everycallcontrol")
|
||||
|
||||
override fun isBlocked(address: String): Single<Boolean> {
|
||||
val uri = Uri.withAppendedPath(CallControl.LOOKUP_TEXT_URI, address)
|
||||
return Single.fromCallable {
|
||||
|
||||
@@ -34,6 +34,8 @@ class QkBlockingClient @Inject constructor(
|
||||
private val blockingRepo: BlockingRepository
|
||||
) : BlockingClient {
|
||||
|
||||
override fun isAvailable(): Boolean = true
|
||||
|
||||
override fun isBlocked(address: String): Single<Boolean> = Single.fromCallable {
|
||||
when {
|
||||
Build.VERSION.SDK_INT >= 24 -> BlockedNumberContract.isBlocked(context, address)
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.os.IBinder
|
||||
import android.os.Message
|
||||
import android.os.Messenger
|
||||
import androidx.core.os.bundleOf
|
||||
import com.moez.QKSMS.common.util.extensions.isInstalled
|
||||
import com.moez.QKSMS.util.tryOrNull
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Single
|
||||
@@ -47,6 +48,11 @@ class ShouldIAnswerBlockingClient @Inject constructor(
|
||||
const val GET_NUMBER_RATING = 1
|
||||
}
|
||||
|
||||
override fun isAvailable(): Boolean = listOf("org.mistergroup.shouldianswer",
|
||||
"org.mistergroup.shouldianswerpersonal",
|
||||
"org.mistergroup.muzutozvednout")
|
||||
.any(context::isInstalled)
|
||||
|
||||
/**
|
||||
* Return a Single<Boolean> which emits whether or not the given [address] should be blocked
|
||||
*/
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.moez.QKSMS.util
|
||||
|
||||
import timber.log.Timber
|
||||
|
||||
fun <T> tryOrNull(logOnError: Boolean = true, body: () -> T?): T? {
|
||||
return try {
|
||||
body()
|
||||
} catch (e: Exception) {
|
||||
if (logOnError) {
|
||||
Timber.w(e)
|
||||
}
|
||||
|
||||
null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user