feat: improve SIM color visibility (#416)

* feat: improve SIM color visibility

* style: format code
This commit is contained in:
Naveen Singh
2025-06-05 19:30:00 +05:30
committed by GitHub
parent 7cb420b99e
commit 4e0eee5ea1
5 changed files with 26 additions and 9 deletions

View File

@@ -625,7 +625,9 @@ class CallActivity : SimpleActivity() {
callSimId.text = sim.id.toString()
callSimId.beVisible()
callSimImage.beVisible()
callSimImage.applyColorFilter(sim.color.adjustSimColorForBackground(getProperBackgroundColor()))
val simColor = sim.color.adjustForContrast(getProperBackgroundColor())
callSimId.setTextColor(simColor.getContrastColor())
callSimImage.applyColorFilter(simColor)
}
val acceptDrawableId = when (index) {

View File

@@ -57,6 +57,7 @@ class RecentCallsAdapter(
private var durationPadding = resources.getDimension(R.dimen.normal_margin).toInt()
private var phoneNumberUtilInstance: PhoneNumberUtil = PhoneNumberUtil.getInstance()
private var phoneNumberOfflineGeocoderInstance: PhoneNumberOfflineGeocoder = PhoneNumberOfflineGeocoder.getInstance()
private val cachedSimColors = HashMap<Pair<Int,Int>, Int>()
init {
initDrawables()
@@ -537,8 +538,9 @@ class RecentCallsAdapter(
itemRecentsSimImage.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
itemRecentsSimId.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
if (areMultipleSIMsAvailable && call.simID != -1) {
itemRecentsSimImage.applyColorFilter(call.simColor.adjustSimColorForBackground(backgroundColor))
itemRecentsSimId.setTextColor(backgroundColor)
val simColor = getAdjustedSimColor(call.simColor)
itemRecentsSimImage.applyColorFilter(simColor)
itemRecentsSimId.setTextColor(simColor.getContrastColor())
itemRecentsSimId.text = call.simID.toString()
}
@@ -583,6 +585,12 @@ class RecentCallsAdapter(
}
}
private fun getAdjustedSimColor(simColor: Int): Int {
return cachedSimColors.getOrPut(simColor to backgroundColor) {
simColor.adjustForContrast(backgroundColor)
}
}
private inner class RecentCallDateViewHolder(val binding: ItemRecentsDateBinding) : ViewHolder(binding.root) {
fun bind(date: CallLogItem.Date) {
binding.dateTextView.apply {

View File

@@ -18,7 +18,7 @@ val Context.powerManager: PowerManager get() = getSystemService(Context.POWER_SE
@SuppressLint("MissingPermission")
fun Context.getAvailableSIMCardLabels(): List<SIMAccount> {
val SIMAccounts = mutableListOf<SIMAccount>()
val simAccounts = mutableListOf<SIMAccount>()
try {
telecomManager.callCapablePhoneAccounts.forEachIndexed { index, account ->
val phoneAccount = telecomManager.getPhoneAccount(account)
@@ -29,12 +29,20 @@ fun Context.getAvailableSIMCardLabels(): List<SIMAccount> {
label += " ($address)"
}
val SIM = SIMAccount(index + 1, phoneAccount.accountHandle, label, address.substringAfter("tel:"), phoneAccount.highlightColor)
SIMAccounts.add(SIM)
simAccounts.add(
SIMAccount(
id = index + 1,
handle = phoneAccount.accountHandle,
label = label,
phoneNumber = address.substringAfter("tel:"),
color = phoneAccount.highlightColor
)
)
}
} catch (ignored: Exception) {
}
return SIMAccounts
return simAccounts
}
@SuppressLint("MissingPermission")

View File

@@ -63,7 +63,6 @@
android:gravity="center"
android:textColor="@color/md_grey_black"
android:textSize="@dimen/small_text_size"
android:textStyle="bold"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/item_recents_sim_image"
app:layout_constraintEnd_toEndOf="@+id/item_recents_sim_image"

View File

@@ -8,7 +8,7 @@ detekt = "1.23.8"
#Eventbus
eventbus = "3.3.1"
#Fossify
commons = "3.0.1"
commons = "3.0.3"
#Gradle
gradlePlugins-agp = "8.10.1"
#Other