mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Remove ComposeText and SendButton sms/mms transport complexity.
This commit is contained in:
committed by
Alex Hart
parent
2f9498e137
commit
b30f47bac4
@@ -1,21 +1,16 @@
|
||||
package org.thoughtcrime.securesms.conversation
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.CharacterCalculator
|
||||
import org.thoughtcrime.securesms.util.MmsCharacterCalculator
|
||||
import org.thoughtcrime.securesms.util.PushCharacterCalculator
|
||||
import org.thoughtcrime.securesms.util.SmsCharacterCalculator
|
||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat
|
||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
/**
|
||||
@@ -51,10 +46,6 @@ sealed class MessageSendType(
|
||||
return characterCalculator.calculateCharacters(body)
|
||||
}
|
||||
|
||||
fun getSimSubscriptionIdOr(fallback: Int): Int {
|
||||
return simSubscriptionId ?: fallback
|
||||
}
|
||||
|
||||
open fun getTitle(context: Context): String {
|
||||
return context.getString(titleRes)
|
||||
}
|
||||
@@ -126,45 +117,14 @@ sealed class MessageSendType(
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private val TAG = Log.tag(MessageSendType::class.java)
|
||||
|
||||
/**
|
||||
* Returns a list of all available [MessageSendType]s. Requires [Manifest.permission.READ_PHONE_STATE] in order to get available
|
||||
* SMS options.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getAllAvailable(context: Context, isMedia: Boolean = false): List<MessageSendType> {
|
||||
val options: MutableList<MessageSendType> = mutableListOf()
|
||||
|
||||
options += SignalMessageSendType
|
||||
|
||||
if (SignalStore.misc().smsExportPhase.allowSmsFeatures()) {
|
||||
try {
|
||||
val subscriptions: Collection<SubscriptionInfoCompat> = SubscriptionManagerCompat(context).activeAndReadySubscriptionInfos
|
||||
|
||||
if (subscriptions.size < 2) {
|
||||
options += if (isMedia) MmsMessageSendType() else SmsMessageSendType()
|
||||
} else {
|
||||
options += subscriptions.map {
|
||||
if (isMedia) {
|
||||
MmsMessageSendType(simName = it.displayName, simSubscriptionId = it.subscriptionId)
|
||||
} else {
|
||||
SmsMessageSendType(simName = it.displayName, simSubscriptionId = it.subscriptionId)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log.w(TAG, "Did not have permission to get SMS subscription details!")
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
fun getAllAvailable(): List<MessageSendType> {
|
||||
return listOf(SignalMessageSendType)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getFirstForTransport(context: Context, isMedia: Boolean, transportType: TransportType): MessageSendType {
|
||||
return getAllAvailable(context, isMedia).firstOrNull { it.transportType == transportType } ?: throw IllegalArgumentException("No options available for desired type $transportType!")
|
||||
fun getFirstForTransport(transportType: TransportType): MessageSendType {
|
||||
return getAllAvailable().firstOrNull { it.transportType == transportType } ?: throw IllegalArgumentException("No options available for desired type $transportType!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ object Multiselect {
|
||||
return false
|
||||
}
|
||||
|
||||
val sendType: MessageSendType = MessageSendType.getFirstForTransport(context, true, MessageSendType.TransportType.SMS)
|
||||
val sendType: MessageSendType = MessageSendType.getFirstForTransport(MessageSendType.TransportType.SMS)
|
||||
|
||||
val mmsConstraints = MediaConstraints.getMmsMediaConstraints(sendType.simSubscriptionId ?: -1)
|
||||
return mmsConstraints.isSatisfied(context, mediaUri, mediaType, mediaSize) || mmsConstraints.canResize(mediaType)
|
||||
@@ -107,7 +107,7 @@ object Multiselect {
|
||||
return false
|
||||
}
|
||||
|
||||
val sendType: MessageSendType = MessageSendType.getFirstForTransport(context, true, MessageSendType.TransportType.SMS)
|
||||
val sendType: MessageSendType = MessageSendType.getFirstForTransport(MessageSendType.TransportType.SMS)
|
||||
|
||||
val mmsConstraints = MediaConstraints.getMmsMediaConstraints(sendType.simSubscriptionId ?: -1)
|
||||
return mmsConstraints.isSatisfied(context, attachment) || mmsConstraints.canResize(attachment)
|
||||
|
||||
@@ -913,7 +913,6 @@ class ConversationFragment :
|
||||
setOnClickListener(sendButtonListener)
|
||||
setScheduledSendListener(sendButtonListener)
|
||||
isEnabled = true
|
||||
sendButton.triggerSelectedChangedEvent()
|
||||
}
|
||||
|
||||
sendEditButton.setOnClickListener { handleSendEditMessage() }
|
||||
|
||||
Reference in New Issue
Block a user