mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-02-12 17:40:38 +01:00
adding an optional call confirmation dialog
This commit is contained in:
parent
618a88a09c
commit
79b3ad0721
@ -55,6 +55,6 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:dcbd6eca15'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:11c7236fdb'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a'
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupDefaultTab()
|
||||
setupGroupSubsequentCalls()
|
||||
setupStartNameWithSurname()
|
||||
setupShowCallConfirmation()
|
||||
updateTextColors(settings_holder)
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
@ -147,4 +148,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
config.startNameWithSurname = settings_start_with_surname.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowCallConfirmation() {
|
||||
settings_show_call_confirmation.isChecked = config.showCallConfirmation
|
||||
settings_show_call_confirmation_holder.setOnClickListener {
|
||||
settings_show_call_confirmation.toggle()
|
||||
config.showCallConfirmation = settings_show_call_confirmation.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||
@ -14,6 +15,7 @@ import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.interfaces.RefreshItemsListener
|
||||
import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
||||
import java.util.*
|
||||
@ -72,18 +74,12 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||
val currAdapter = fragment_list.adapter
|
||||
if (currAdapter == null) {
|
||||
ContactsAdapter(activity as SimpleActivity, contacts, fragment_list, this, showDeleteButton = false) {
|
||||
val phoneNumbers = (it as SimpleContact).phoneNumbers
|
||||
if (phoneNumbers.size <= 1) {
|
||||
activity?.launchCallIntent(it.phoneNumbers.first())
|
||||
if (context.config.showCallConfirmation) {
|
||||
CallConfirmationDialog(activity as SimpleActivity, (it as SimpleContact).name) {
|
||||
callContact(it)
|
||||
}
|
||||
} else {
|
||||
val items = ArrayList<RadioItem>()
|
||||
phoneNumbers.forEachIndexed { index, phoneNumber ->
|
||||
items.add(RadioItem(index, phoneNumber))
|
||||
}
|
||||
|
||||
RadioGroupDialog(activity!!, items) {
|
||||
activity?.launchCallIntent(phoneNumbers[it as Int])
|
||||
}
|
||||
callContact(it as SimpleContact)
|
||||
}
|
||||
}.apply {
|
||||
fragment_list.adapter = this
|
||||
@ -94,6 +90,22 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||
}
|
||||
}
|
||||
|
||||
private fun callContact(simpleContact: SimpleContact) {
|
||||
val phoneNumbers = simpleContact.phoneNumbers
|
||||
if (phoneNumbers.size <= 1) {
|
||||
activity?.launchCallIntent(phoneNumbers.first())
|
||||
} else {
|
||||
val items = ArrayList<RadioItem>()
|
||||
phoneNumbers.forEachIndexed { index, phoneNumber ->
|
||||
items.add(RadioItem(index, phoneNumber))
|
||||
}
|
||||
|
||||
RadioGroupDialog(activity!!, items) {
|
||||
activity?.launchCallIntent(phoneNumbers[it as Int])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLetterFastscroller(contacts: ArrayList<SimpleContact>) {
|
||||
letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
|
||||
try {
|
||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.dialer.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALL_LOG
|
||||
@ -90,7 +91,14 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
||||
val currAdapter = recents_list.adapter
|
||||
if (currAdapter == null) {
|
||||
RecentCallsAdapter(activity as SimpleActivity, recents, recents_list, this) {
|
||||
activity?.launchCallIntent((it as RecentCall).phoneNumber)
|
||||
val recentCall = it as RecentCall
|
||||
if (context.config.showCallConfirmation) {
|
||||
CallConfirmationDialog(activity as SimpleActivity, recentCall.name) {
|
||||
activity?.launchCallIntent(recentCall.phoneNumber)
|
||||
}
|
||||
} else {
|
||||
activity?.launchCallIntent(recentCall.phoneNumber)
|
||||
}
|
||||
}.apply {
|
||||
recents_list.adapter = this
|
||||
}
|
||||
|
@ -3,13 +3,15 @@ package com.simplemobiletools.dialer.models
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
||||
|
||||
data class RecentCall(var id: Int, var phoneNumber: String, var name: String, var photoUri: String, var startTS: Int, var duration: Int, var type: Int,
|
||||
var neighbourIDs: ArrayList<Int>, val simID: Int) {
|
||||
data class RecentCall(
|
||||
var id: Int, var phoneNumber: String, var name: String, var photoUri: String, var startTS: Int, var duration: Int, var type: Int,
|
||||
var neighbourIDs: ArrayList<Int>, val simID: Int
|
||||
) {
|
||||
fun doesContainPhoneNumber(text: String): Boolean {
|
||||
val normalizedText = text.normalizePhoneNumber()
|
||||
return PhoneNumberUtils.compare(phoneNumber.normalizePhoneNumber(), normalizedText) ||
|
||||
phoneNumber.contains(text) ||
|
||||
phoneNumber.normalizePhoneNumber().contains(normalizedText) ||
|
||||
phoneNumber.contains(normalizedText)
|
||||
phoneNumber.contains(text) ||
|
||||
phoneNumber.normalizePhoneNumber().contains(normalizedText) ||
|
||||
phoneNumber.contains(normalizedText)
|
||||
}
|
||||
}
|
||||
|
@ -248,5 +248,28 @@
|
||||
app:switchPadding="@dimen/medium_margin" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_call_confirmation_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_show_call_confirmation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/show_call_confirmation_dialog"
|
||||
app:switchPadding="@dimen/medium_margin" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
Loading…
x
Reference in New Issue
Block a user