Add block/archive notification actions, and block swipe action

Closes #1575, closes #943
This commit is contained in:
Moez Bhatti
2020-02-29 19:54:40 -05:00
parent 853acaa42c
commit e2f4b92609
20 changed files with 201 additions and 40 deletions
@@ -0,0 +1,52 @@
/*
* 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.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.moez.QKSMS.blocking.BlockingClient
import com.moez.QKSMS.interactor.MarkBlocked
import com.moez.QKSMS.repository.ConversationRepository
import com.moez.QKSMS.util.Preferences
import dagger.android.AndroidInjection
import javax.inject.Inject
class BlockThreadReceiver : BroadcastReceiver() {
@Inject lateinit var blockingClient: BlockingClient
@Inject lateinit var conversationRepo: ConversationRepository
@Inject lateinit var markBlocked: MarkBlocked
@Inject lateinit var prefs: Preferences
override fun onReceive(context: Context, intent: Intent) {
AndroidInjection.inject(this, context)
val pendingResult = goAsync()
val threadId = intent.getLongExtra("threadId", 0)
val conversation = conversationRepo.getConversation(threadId)!!
val blockingManager = prefs.blockingManager.get()
blockingClient
.block(conversation.recipients.map { it.address })
.andThen(markBlocked.buildObservable(MarkBlocked.Params(listOf(threadId), blockingManager, null)))
.subscribe { pendingResult.finish() }
}
}