mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
Update android-smsmms for cleaner MmsReceiver
This commit is contained in:
@@ -66,7 +66,7 @@ dependencies {
|
|||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:b4cc381943'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:b4cc381943'
|
||||||
implementation 'org.greenrobot:eventbus:3.3.1'
|
implementation 'org.greenrobot:eventbus:3.3.1'
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
||||||
implementation 'com.github.tibbi:android-smsmms:33fcaf94d9'
|
implementation 'com.github.esensar:android-smsmms:f6551b0b4f'
|
||||||
implementation "me.leolin:ShortcutBadger:1.1.22"
|
implementation "me.leolin:ShortcutBadger:1.1.22"
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
package com.simplemobiletools.smsmessenger.receivers
|
package com.simplemobiletools.smsmessenger.receivers
|
||||||
|
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
@@ -10,9 +8,6 @@ import android.preference.PreferenceManager
|
|||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.klinker.android.send_message.MmsReceivedReceiver
|
import com.klinker.android.send_message.MmsReceivedReceiver
|
||||||
import com.klinker.android.send_message.MmsReceivedReceiver.MmscInformation
|
|
||||||
import com.klinker.android.send_message.MmsReceivedReceiver.SUBSCRIPTION_ID
|
|
||||||
import com.klinker.android.send_message.Utils
|
|
||||||
import com.simplemobiletools.commons.extensions.getStringValue
|
import com.simplemobiletools.commons.extensions.getStringValue
|
||||||
import com.simplemobiletools.commons.extensions.isNumberBlocked
|
import com.simplemobiletools.commons.extensions.isNumberBlocked
|
||||||
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
||||||
@@ -25,11 +20,11 @@ import com.simplemobiletools.smsmessenger.extensions.*
|
|||||||
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
||||||
|
|
||||||
// more info at https://github.com/klinker41/android-smsmms
|
// more info at https://github.com/klinker41/android-smsmms
|
||||||
class MmsReceiver : BroadcastReceiver() {
|
class MmsReceiver : MmsReceivedReceiver() {
|
||||||
|
|
||||||
private var carriers = mutableMapOf<Int, MmscInformation>()
|
private var carriers = mutableMapOf<Int, MmscInformation>()
|
||||||
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
private fun populateMmscInformation(context: Context, subscriptionId: Int) {
|
||||||
if (isRPlus() && carriers.isNotEmpty()) {
|
if (isRPlus() && carriers.isNotEmpty()) {
|
||||||
// This information is stored by ApnUtils from android-smsmms
|
// This information is stored by ApnUtils from android-smsmms
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).apply {
|
PreferenceManager.getDefaultSharedPreferences(context).apply {
|
||||||
@@ -40,7 +35,6 @@ class MmsReceiver : BroadcastReceiver() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val subscriptionId = intent?.getIntExtra(SUBSCRIPTION_ID, Utils.getDefaultSubscriptionId()) ?: Utils.getDefaultSubscriptionId()
|
|
||||||
if (carriers.containsKey(subscriptionId).not()) {
|
if (carriers.containsKey(subscriptionId).not()) {
|
||||||
val baseUri = if (isQPlus()) {
|
val baseUri = if (isQPlus()) {
|
||||||
Telephony.Carriers.SIM_APN_URI
|
Telephony.Carriers.SIM_APN_URI
|
||||||
@@ -56,7 +50,7 @@ class MmsReceiver : BroadcastReceiver() {
|
|||||||
val selection = "${Telephony.Carriers.TYPE} LIKE ?"
|
val selection = "${Telephony.Carriers.TYPE} LIKE ?"
|
||||||
val selectionArgs = arrayOf("%mms%")
|
val selectionArgs = arrayOf("%mms%")
|
||||||
|
|
||||||
context?.queryCursor(uri, projection = projection, selection = selection, selectionArgs = selectionArgs) { cursor ->
|
context.queryCursor(uri, projection = projection, selection = selection, selectionArgs = selectionArgs) { cursor ->
|
||||||
carriers[subscriptionId] = MmscInformation(
|
carriers[subscriptionId] = MmscInformation(
|
||||||
cursor.getStringValue(Telephony.Carriers.MMSC),
|
cursor.getStringValue(Telephony.Carriers.MMSC),
|
||||||
cursor.getStringValue(Telephony.Carriers.MMSPROXY),
|
cursor.getStringValue(Telephony.Carriers.MMSPROXY),
|
||||||
@@ -65,19 +59,19 @@ class MmsReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val mmscInformation = if (isRPlus()) {
|
}
|
||||||
|
|
||||||
|
private fun getMmscInformation(subscriptionId: Int): MmscInformation? {
|
||||||
|
return if (isRPlus()) {
|
||||||
carriers[0]
|
carriers[0]
|
||||||
} else {
|
} else {
|
||||||
val subscriptionId = intent?.getIntExtra(SUBSCRIPTION_ID, Utils.getDefaultSubscriptionId()) ?: Utils.getDefaultSubscriptionId()
|
|
||||||
carriers[subscriptionId]
|
carriers[subscriptionId]
|
||||||
}
|
}
|
||||||
MmsReceivedReceiverImplementation(mmscInformation).onReceive(context, intent)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private class MmsReceivedReceiverImplementation(private val mmscInformation: MmscInformation?) : MmsReceivedReceiver() {
|
override fun getMmscInfoForReceptionAck(context: Context, subscriptionId: Int): MmscInformation? {
|
||||||
override fun getMmscInfoForReceptionAck(): MmscInformation? {
|
populateMmscInformation(context, subscriptionId)
|
||||||
return mmscInformation
|
return getMmscInformation(subscriptionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAddressBlocked(context: Context, address: String): Boolean {
|
override fun isAddressBlocked(context: Context, address: String): Boolean {
|
||||||
|
Reference in New Issue
Block a user