show the SIM card ID at messages
This commit is contained in:
parent
516aab0d5c
commit
64bb563ef6
4 changed files with 56 additions and 8 deletions
|
|
@ -370,16 +370,24 @@ class ThreadActivity : SimpleActivity() {
|
|||
showSelectedContacts()
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun getThreadItems(): ArrayList<ThreadItem> {
|
||||
messages.sortBy { it.date }
|
||||
|
||||
val subscriptionIdToSimId = HashMap<Int, String>()
|
||||
subscriptionIdToSimId[-1] = "?"
|
||||
SubscriptionManager.from(this).activeSubscriptionInfoList.forEachIndexed { index, subscriptionInfo ->
|
||||
subscriptionIdToSimId[subscriptionInfo.subscriptionId] = "${index + 1}"
|
||||
}
|
||||
|
||||
val items = ArrayList<ThreadItem>()
|
||||
var prevDateTime = 0
|
||||
var hadUnreadItems = false
|
||||
messages.forEach {
|
||||
// do not show the date/time above every message, only if the difference between the 2 messages is at least MIN_DATE_TIME_DIFF_SECS
|
||||
if (it.date - prevDateTime > MIN_DATE_TIME_DIFF_SECS) {
|
||||
items.add(ThreadDateTime(it.date))
|
||||
val simCardID = subscriptionIdToSimId[it.subscriptionId] ?: "?"
|
||||
items.add(ThreadDateTime(it.date, simCardID))
|
||||
prevDateTime = it.date
|
||||
}
|
||||
items.add(it)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.smsmessenger.adapters
|
|||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.telephony.SubscriptionManager
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
|
@ -42,6 +43,7 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem
|
|||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
|
||||
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
|
||||
private val hasMultipleSIMCards = SubscriptionManager.from(activity).activeSubscriptionInfoList.size > 1
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
|
|
@ -283,6 +285,14 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem
|
|||
view.apply {
|
||||
thread_date_time.text = dateTime.date.formatDateOrTime(context, false)
|
||||
thread_date_time.setTextColor(textColor)
|
||||
|
||||
thread_sim_icon.beVisibleIf(hasMultipleSIMCards)
|
||||
thread_sim_number.beVisibleIf(hasMultipleSIMCards)
|
||||
if (hasMultipleSIMCards) {
|
||||
thread_sim_number.text = dateTime.simID
|
||||
thread_sim_number.setTextColor(textColor.getContrastColor())
|
||||
thread_sim_icon.applyColorFilter(textColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
open class ThreadDateTime(val date: Int) : ThreadItem()
|
||||
open class ThreadDateTime(val date: Int, val simID: String) : ThreadItem()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue