Make formatting phone number optional

This commit is contained in:
Naveen
2024-05-08 05:15:39 +05:30
parent 8924a42aea
commit c800cbd7dc
5 changed files with 39 additions and 4 deletions

View File

@@ -77,6 +77,7 @@ class SettingsActivity : SimpleActivity() {
setupDialPadOpen()
setupGroupSubsequentCalls()
setupStartNameWithSurname()
setupFormatPhoneNumbers()
setupDialpadVibrations()
setupDialpadNumbers()
setupDialpadBeeps()
@@ -253,6 +254,14 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupFormatPhoneNumbers() {
binding.settingsFormatPhoneNumbers.isChecked = config.formatPhoneNumbers
binding.settingsFormatPhoneNumbersHolder.setOnClickListener {
binding.settingsFormatPhoneNumbers.toggle()
config.formatPhoneNumbers = binding.settingsFormatPhoneNumbers.isChecked
}
}
private fun setupDialpadVibrations() {
binding.apply {
settingsDialpadVibration.isChecked = config.dialpadVibration

View File

@@ -429,7 +429,8 @@ class RecentCallsAdapter(
val currentFontSize = fontSize
itemRecentsHolder.isSelected = selectedKeys.contains(call.id)
val name = findContactByCall(call)?.getNameToDisplay() ?: call.name
var nameToShow = if (name == call.phoneNumber) {
val formatPhoneNumbers = activity.config.formatPhoneNumbers
var nameToShow = if (name == call.phoneNumber && formatPhoneNumbers) {
SpannableString(name.formatPhoneNumber())
} else {
SpannableString(name)
@@ -440,7 +441,11 @@ class RecentCallsAdapter(
// show specific number at "Show call details" dialog too
if (refreshItemsListener == null) {
nameToShow = SpannableString("$name - ${call.specificType}, ${call.specificNumber.formatPhoneNumber()}")
nameToShow = if (formatPhoneNumbers) {
SpannableString("$name - ${call.specificType}, ${call.specificNumber.formatPhoneNumber()}")
} else {
SpannableString("$name - ${call.specificType}, ${call.specificNumber}")
}
}
}

View File

@@ -10,6 +10,7 @@ import org.fossify.commons.helpers.ContactsHelper
import org.fossify.commons.helpers.MyContactsContentProvider
import org.fossify.commons.helpers.ensureBackgroundThread
import org.fossify.phone.R
import org.fossify.phone.extensions.config
import org.fossify.phone.extensions.isConference
import org.fossify.phone.models.CallContact
@@ -51,7 +52,12 @@ fun getCallContact(context: Context, call: Call?, callback: (CallContact) -> Uni
}
}
callContact.number = number.formatPhoneNumber()
callContact.number = if (context.config.formatPhoneNumbers) {
number.formatPhoneNumber()
} else {
number
}
val contact = contacts.firstOrNull { it.doesHavePhoneNumber(number) }
if (contact != null) {
callContact.name = contact.getNameToDisplay()

View File

@@ -184,6 +184,21 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_format_phone_numbers_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<org.fossify.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_format_phone_numbers"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/format_phone_numbers" />
</RelativeLayout>
<include
android:id="@+id/settings_general_settings_divider"
layout="@layout/divider" />

View File

@@ -5,7 +5,7 @@ kotlinxSerializationJson = "1.5.1"
#Eventbus
eventbus = "3.3.1"
#Fossify
commons = "d6845038bc"
commons = "bba99193a0"
#Gradle
gradlePlugins-agp = "8.3.2"
#Other