mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
adding an optional call confirmation dialog
This commit is contained in:
@@ -55,6 +55,6 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:dcbd6eca15'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:11c7236fdb'
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a'
|
implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a'
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupDefaultTab()
|
setupDefaultTab()
|
||||||
setupGroupSubsequentCalls()
|
setupGroupSubsequentCalls()
|
||||||
setupStartNameWithSurname()
|
setupStartNameWithSurname()
|
||||||
|
setupShowCallConfirmation()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
@@ -147,4 +148,12 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
config.startNameWithSurname = settings_start_with_surname.isChecked
|
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 android.util.AttributeSet
|
||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
|
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
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.R
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
|
import com.simplemobiletools.dialer.extensions.config
|
||||||
import com.simplemobiletools.dialer.interfaces.RefreshItemsListener
|
import com.simplemobiletools.dialer.interfaces.RefreshItemsListener
|
||||||
import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -72,9 +74,26 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
val currAdapter = fragment_list.adapter
|
val currAdapter = fragment_list.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
ContactsAdapter(activity as SimpleActivity, contacts, fragment_list, this, showDeleteButton = false) {
|
ContactsAdapter(activity as SimpleActivity, contacts, fragment_list, this, showDeleteButton = false) {
|
||||||
val phoneNumbers = (it as SimpleContact).phoneNumbers
|
if (context.config.showCallConfirmation) {
|
||||||
|
CallConfirmationDialog(activity as SimpleActivity, (it as SimpleContact).name) {
|
||||||
|
callContact(it)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callContact(it as SimpleContact)
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
fragment_list.adapter = this
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(currAdapter as ContactsAdapter).updateItems(contacts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun callContact(simpleContact: SimpleContact) {
|
||||||
|
val phoneNumbers = simpleContact.phoneNumbers
|
||||||
if (phoneNumbers.size <= 1) {
|
if (phoneNumbers.size <= 1) {
|
||||||
activity?.launchCallIntent(it.phoneNumbers.first())
|
activity?.launchCallIntent(phoneNumbers.first())
|
||||||
} else {
|
} else {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
phoneNumbers.forEachIndexed { index, phoneNumber ->
|
phoneNumbers.forEachIndexed { index, phoneNumber ->
|
||||||
@@ -85,13 +104,6 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
activity?.launchCallIntent(phoneNumbers[it as Int])
|
activity?.launchCallIntent(phoneNumbers[it as Int])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.apply {
|
|
||||||
fragment_list.adapter = this
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
(currAdapter as ContactsAdapter).updateItems(contacts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLetterFastscroller(contacts: ArrayList<SimpleContact>) {
|
private fun setupLetterFastscroller(contacts: ArrayList<SimpleContact>) {
|
||||||
|
@@ -2,6 +2,7 @@ package com.simplemobiletools.dialer.fragments
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALL_LOG
|
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
|
val currAdapter = recents_list.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
RecentCallsAdapter(activity as SimpleActivity, recents, recents_list, this) {
|
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 {
|
}.apply {
|
||||||
recents_list.adapter = this
|
recents_list.adapter = this
|
||||||
}
|
}
|
||||||
|
@@ -3,8 +3,10 @@ package com.simplemobiletools.dialer.models
|
|||||||
import android.telephony.PhoneNumberUtils
|
import android.telephony.PhoneNumberUtils
|
||||||
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
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,
|
data class RecentCall(
|
||||||
var neighbourIDs: ArrayList<Int>, val simID: Int) {
|
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 {
|
fun doesContainPhoneNumber(text: String): Boolean {
|
||||||
val normalizedText = text.normalizePhoneNumber()
|
val normalizedText = text.normalizePhoneNumber()
|
||||||
return PhoneNumberUtils.compare(phoneNumber.normalizePhoneNumber(), normalizedText) ||
|
return PhoneNumberUtils.compare(phoneNumber.normalizePhoneNumber(), normalizedText) ||
|
||||||
|
@@ -248,5 +248,28 @@
|
|||||||
app:switchPadding="@dimen/medium_margin" />
|
app:switchPadding="@dimen/medium_margin" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</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>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
Reference in New Issue
Block a user