show a Select SIM button at message sending, if multiple are available

This commit is contained in:
tibbi 2020-05-03 22:33:32 +02:00
parent eff3b70c93
commit 49a7cd98f5
4 changed files with 63 additions and 4 deletions

View File

@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.provider.Telephony.SMS_RECEIVED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission

View File

@ -8,6 +8,7 @@ import android.media.MediaMetadataRetriever
import android.net.Uri
import android.os.Bundle
import android.provider.Telephony
import android.telephony.SubscriptionManager
import android.text.TextUtils
import android.view.*
import android.view.inputmethod.EditorInfo
@ -28,6 +29,7 @@ import com.klinker.android.send_message.Settings
import com.klinker.android.send_message.Transaction
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.PERMISSION_READ_PHONE_STATE
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.smsmessenger.R
@ -72,7 +74,16 @@ class ThreadActivity : SimpleActivity() {
bus = EventBus.getDefault()
bus!!.register(this)
handlePermission(PERMISSION_READ_PHONE_STATE) {
if (it) {
setupThread()
} else {
finish()
}
}
}
private fun setupThread() {
ensureBackgroundThread {
messages = getMessages(threadId)
participants = if (messages.isEmpty()) {
@ -210,9 +221,10 @@ class ThreadActivity : SimpleActivity() {
private fun setupButtons() {
updateTextColors(thread_holder)
thread_send_message.applyColorFilter(config.textColor)
confirm_manage_contacts.applyColorFilter(config.textColor)
thread_add_attachment.applyColorFilter(config.textColor)
val textColor = config.textColor
thread_send_message.applyColorFilter(textColor)
confirm_manage_contacts.applyColorFilter(textColor)
thread_add_attachment.applyColorFilter(textColor)
thread_send_message.setOnClickListener {
sendMessage()
@ -251,6 +263,18 @@ class ThreadActivity : SimpleActivity() {
addAttachment(it)
}
}
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList
if (availableSIMs.size > 1) {
thread_select_sim_icon.applyColorFilter(textColor)
thread_select_sim_icon.beVisible()
thread_select_sim_icon.setOnClickListener {
}
thread_select_sim_number.setTextColor(textColor.getContrastColor())
thread_select_sim_number.text = "1"
}
}
private fun blockNumber() {
@ -422,6 +446,7 @@ class ThreadActivity : SimpleActivity() {
val numbers = participants.map { it.phoneNumber }.toTypedArray()
val settings = Settings()
settings.useSystemSending = true
val transaction = Transaction(this, settings)
val message = com.klinker.android.send_message.Message(msg, numbers)

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="m20.6507,3.3384c0,-1.191 -0.9636,-2.1654 -2.1546,-2.1654l-8.6616,0 -6.4962,6.4962 0,12.9923c0,1.191 0.9744,2.1654 2.1654,2.1654l13.0032,0c1.191,0 2.1546,-0.9744 2.1546,-2.1654z" />
</vector>

View File

@ -156,13 +156,37 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginEnd="@dimen/small_margin"
android:layout_toStartOf="@+id/thread_send_message"
android:layout_toStartOf="@+id/thread_select_sim_icon"
android:layout_toEndOf="@+id/thread_add_attachment"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:hint="@string/type_a_message"
android:minHeight="@dimen/normal_icon_size" />
<ImageView
android:id="@+id/thread_select_sim_icon"
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_alignParentBottom="true"
android:layout_marginTop="@dimen/small_margin"
android:layout_toStartOf="@+id/thread_send_message"
android:alpha="0.9"
android:background="?selectableItemBackgroundBorderless"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_sim_vector" />
<TextView
android:id="@+id/thread_select_sim_number"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignStart="@+id/thread_select_sim_icon"
android:layout_alignTop="@+id/thread_select_sim_icon"
android:layout_alignEnd="@+id/thread_select_sim_icon"
android:layout_alignBottom="@+id/thread_select_sim_icon"
android:gravity="center"
android:textSize="@dimen/normal_text_size"
tools:text="1" />
<ImageView
android:id="@+id/thread_send_message"
android:layout_width="@dimen/normal_icon_size"