mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-17 04:00:35 +01:00
allow toggling SIM cards at sending messages
This commit is contained in:
parent
49a7cd98f5
commit
f5d3c2ab70
@ -50,10 +50,12 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
private val PICK_ATTACHMENT_INTENT = 1
|
private val PICK_ATTACHMENT_INTENT = 1
|
||||||
|
|
||||||
private var threadId = 0
|
private var threadId = 0
|
||||||
|
private var currentSIMCardIndex = 0
|
||||||
private var threadItems = ArrayList<ThreadItem>()
|
private var threadItems = ArrayList<ThreadItem>()
|
||||||
private var bus: EventBus? = null
|
private var bus: EventBus? = null
|
||||||
private var participants = ArrayList<Contact>()
|
private var participants = ArrayList<Contact>()
|
||||||
private var messages = ArrayList<Message>()
|
private var messages = ArrayList<Message>()
|
||||||
|
private val availableSIMCards = ArrayList<SIMCard>()
|
||||||
private var attachmentUris = LinkedHashSet<Uri>()
|
private var attachmentUris = LinkedHashSet<Uri>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -266,10 +268,27 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
|
|
||||||
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList
|
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList
|
||||||
if (availableSIMs.size > 1) {
|
if (availableSIMs.size > 1) {
|
||||||
|
availableSIMs.forEachIndexed { index, subscriptionInfo ->
|
||||||
|
var label = subscriptionInfo.displayName.toString()
|
||||||
|
if (subscriptionInfo.number.isNotEmpty()) {
|
||||||
|
label += " (${subscriptionInfo.number})"
|
||||||
|
}
|
||||||
|
val SIMCard = SIMCard(index + 1, subscriptionInfo.subscriptionId, label)
|
||||||
|
availableSIMCards.add(SIMCard)
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSIMCardIndex = 0
|
||||||
thread_select_sim_icon.applyColorFilter(textColor)
|
thread_select_sim_icon.applyColorFilter(textColor)
|
||||||
thread_select_sim_icon.beVisible()
|
thread_select_sim_icon.beVisible()
|
||||||
thread_select_sim_icon.setOnClickListener {
|
thread_select_sim_number.beVisible()
|
||||||
|
|
||||||
|
if (availableSIMCards.isNotEmpty()) {
|
||||||
|
thread_select_sim_icon.setOnClickListener {
|
||||||
|
currentSIMCardIndex = (currentSIMCardIndex + 1) % availableSIMCards.size
|
||||||
|
val currentSIMCard = availableSIMCards[currentSIMCardIndex]
|
||||||
|
thread_select_sim_number.text = currentSIMCard.id.toString()
|
||||||
|
toast(currentSIMCard.label)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_select_sim_number.setTextColor(textColor.getContrastColor())
|
thread_select_sim_number.setTextColor(textColor.getContrastColor())
|
||||||
@ -447,6 +466,11 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
val settings = Settings()
|
val settings = Settings()
|
||||||
settings.useSystemSending = true
|
settings.useSystemSending = true
|
||||||
|
|
||||||
|
val SIMId = availableSIMCards.getOrNull(currentSIMCardIndex)?.subscriptionId
|
||||||
|
if (SIMId != null) {
|
||||||
|
settings.subscriptionId = SIMId
|
||||||
|
}
|
||||||
|
|
||||||
val transaction = Transaction(this, settings)
|
val transaction = Transaction(this, settings)
|
||||||
val message = com.klinker.android.send_message.Message(msg, numbers)
|
val message = com.klinker.android.send_message.Message(msg, numbers)
|
||||||
|
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
package com.simplemobiletools.smsmessenger.models
|
||||||
|
|
||||||
|
data class SIMCard(val id: Int, val subscriptionId: Int, val label: String)
|
@ -173,7 +173,8 @@
|
|||||||
android:alpha="0.9"
|
android:alpha="0.9"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:padding="@dimen/normal_margin"
|
android:padding="@dimen/normal_margin"
|
||||||
android:src="@drawable/ic_sim_vector" />
|
android:src="@drawable/ic_sim_vector"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/thread_select_sim_number"
|
android:id="@+id/thread_select_sim_number"
|
||||||
@ -185,6 +186,7 @@
|
|||||||
android:layout_alignBottom="@+id/thread_select_sim_icon"
|
android:layout_alignBottom="@+id/thread_select_sim_icon"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
|
android:visibility="gone"
|
||||||
tools:text="1" />
|
tools:text="1" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
Loading…
x
Reference in New Issue
Block a user