forked from upstream-mirrors/quik
Refactor ExternalBlockingManager to BlockingClient
This commit is contained in:
+3
-3
@@ -16,7 +16,7 @@
|
||||
* 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.manager
|
||||
package com.moez.QKSMS.blocking
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
@@ -35,10 +35,10 @@ import io.reactivex.subjects.SingleSubject
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class ExternalBlockingManagerImpl @Inject constructor(
|
||||
class ShouldIAnswerBlockingClient @Inject constructor(
|
||||
private val context: Context,
|
||||
private val prefs: Preferences
|
||||
) : ExternalBlockingManager {
|
||||
) : BlockingClient {
|
||||
|
||||
companion object {
|
||||
const val RATING_UNKNOWN = 0
|
||||
+2
-2
@@ -16,11 +16,11 @@
|
||||
* 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.manager
|
||||
package com.moez.QKSMS.blocking
|
||||
|
||||
import io.reactivex.Single
|
||||
|
||||
interface ExternalBlockingManager {
|
||||
interface BlockingClient {
|
||||
|
||||
/**
|
||||
* Return a Single<Boolean> which emits whether or not the given [address] should be blocked
|
||||
@@ -19,9 +19,9 @@
|
||||
package com.moez.QKSMS.interactor
|
||||
|
||||
import android.net.Uri
|
||||
import com.moez.QKSMS.blocking.BlockingClient
|
||||
import com.moez.QKSMS.extensions.mapNotNull
|
||||
import com.moez.QKSMS.manager.ActiveConversationManager
|
||||
import com.moez.QKSMS.manager.ExternalBlockingManager
|
||||
import com.moez.QKSMS.manager.NotificationManager
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
import com.moez.QKSMS.repository.MessageRepository
|
||||
@@ -32,7 +32,7 @@ import javax.inject.Inject
|
||||
class ReceiveMms @Inject constructor(
|
||||
private val activeConversationManager: ActiveConversationManager,
|
||||
private val conversationRepo: ConversationRepository,
|
||||
private val externalBlockingManager: ExternalBlockingManager,
|
||||
private val blockingClient: BlockingClient,
|
||||
private val syncManager: SyncRepository,
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager,
|
||||
@@ -54,7 +54,7 @@ class ReceiveMms @Inject constructor(
|
||||
// to check if it should be blocked after we've pulled it into realm. If it
|
||||
// turns out that it should be blocked, then delete it
|
||||
// TODO Don't store blocked messages in the first place
|
||||
!externalBlockingManager.shouldBlock(message.address).blockingGet().also { blocked ->
|
||||
!blockingClient.shouldBlock(message.address).blockingGet().also { blocked ->
|
||||
if (blocked) messageRepo.deleteMessages(message.id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
package com.moez.QKSMS.interactor
|
||||
|
||||
import android.telephony.SmsMessage
|
||||
import com.moez.QKSMS.blocking.BlockingClient
|
||||
import com.moez.QKSMS.extensions.mapNotNull
|
||||
import com.moez.QKSMS.manager.ExternalBlockingManager
|
||||
import com.moez.QKSMS.manager.NotificationManager
|
||||
import com.moez.QKSMS.manager.ShortcutManager
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
@@ -30,7 +30,7 @@ import javax.inject.Inject
|
||||
|
||||
class ReceiveSms @Inject constructor(
|
||||
private val conversationRepo: ConversationRepository,
|
||||
private val externalBlockingManager: ExternalBlockingManager,
|
||||
private val blockingClient: BlockingClient,
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager,
|
||||
private val updateBadge: UpdateBadge,
|
||||
@@ -45,7 +45,7 @@ class ReceiveSms @Inject constructor(
|
||||
.filter {
|
||||
// Don't continue if the sender is blocked
|
||||
val address = it.messages[0].displayOriginatingAddress
|
||||
!externalBlockingManager.shouldBlock(address).blockingGet()
|
||||
!blockingClient.shouldBlock(address).blockingGet()
|
||||
}
|
||||
.map {
|
||||
val messages = it.messages
|
||||
|
||||
@@ -73,7 +73,6 @@ class BlockedViewModel @Inject constructor(
|
||||
"org.mistergroup.shouldianswerpersonal",
|
||||
"org.mistergroup.muzutozvednout")
|
||||
.any(context::isInstalled)
|
||||
|
||||
}
|
||||
.map { installed ->
|
||||
if (!installed) {
|
||||
|
||||
@@ -25,6 +25,8 @@ import android.content.Context
|
||||
import android.preference.PreferenceManager
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.f2prateek.rx.preferences2.RxSharedPreferences
|
||||
import com.moez.QKSMS.blocking.BlockingClient
|
||||
import com.moez.QKSMS.blocking.ShouldIAnswerBlockingClient
|
||||
import com.moez.QKSMS.common.ViewModelFactory
|
||||
import com.moez.QKSMS.common.util.NotificationManagerImpl
|
||||
import com.moez.QKSMS.common.util.ShortcutManagerImpl
|
||||
@@ -40,8 +42,6 @@ import com.moez.QKSMS.manager.AnalyticsManager
|
||||
import com.moez.QKSMS.manager.AnalyticsManagerImpl
|
||||
import com.moez.QKSMS.manager.ChangelogManager
|
||||
import com.moez.QKSMS.manager.ChangelogManagerImpl
|
||||
import com.moez.QKSMS.manager.ExternalBlockingManager
|
||||
import com.moez.QKSMS.manager.ExternalBlockingManagerImpl
|
||||
import com.moez.QKSMS.manager.KeyManager
|
||||
import com.moez.QKSMS.manager.KeyManagerImpl
|
||||
import com.moez.QKSMS.manager.NotificationManager
|
||||
@@ -129,7 +129,7 @@ class AppModule(private var application: Application) {
|
||||
fun provideAnalyticsManager(manager: AnalyticsManagerImpl): AnalyticsManager = manager
|
||||
|
||||
@Provides
|
||||
fun externalBlockingManager(manager: ExternalBlockingManagerImpl): ExternalBlockingManager = manager
|
||||
fun externalBlockingManager(manager: ShouldIAnswerBlockingClient): BlockingClient = manager
|
||||
|
||||
@Provides
|
||||
fun changelogManager(manager: ChangelogManagerImpl): ChangelogManager = manager
|
||||
|
||||
Reference in New Issue
Block a user