Sync MMS on sending and on failure

This commit is contained in:
Moez Bhatti
2018-01-14 18:59:53 -05:00
parent c4b672f260
commit 45f1cb1bc8
11 changed files with 229 additions and 139 deletions
@@ -134,7 +134,6 @@ class MessagesAdapter @Inject constructor(
bindMmsPreview(view, position)
bindStatus(view, position)
bindGrouping(view, position)
view.messageBackground.invalidateOutline()
}
private fun bindMmsPreview(view: View, position: Int) {
@@ -23,12 +23,12 @@ import android.content.Intent
import android.net.Uri
import com.klinker.android.send_message.MmsSentReceiver
import common.di.appComponent
import interactor.MarkMmsSent
import interactor.SyncMessage
import javax.inject.Inject
class MmsSentReceiver : MmsSentReceiver() {
@Inject lateinit var markMmsSent: MarkMmsSent
@Inject lateinit var syncMessage: SyncMessage
override fun onReceive(context: Context, intent: Intent) {
super.onReceive(context, intent)
@@ -36,7 +36,7 @@ class MmsSentReceiver : MmsSentReceiver() {
Uri.parse(intent.getStringExtra("content_uri"))?.let { uri ->
val pendingResult = goAsync()
markMmsSent.execute(uri) { pendingResult.finish() }
syncMessage.execute(uri) { pendingResult.finish() }
}
}
@@ -0,0 +1,45 @@
/*
* 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 presentation.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.net.Uri
import common.di.appComponent
import interactor.SyncMessage
import javax.inject.Inject
class MmsUpdatedReceiver : BroadcastReceiver() {
companion object {
const val URI = "uri"
}
@Inject lateinit var syncMessage: SyncMessage
override fun onReceive(context: Context, intent: Intent) {
appComponent.inject(this)
intent.getStringExtra(URI)?.let { uriString ->
val pendingResult = goAsync()
syncMessage.execute(Uri.parse(uriString)) { pendingResult.finish() }
}
}
}