Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement redial feature #703

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.os.Looper
import android.provider.Telephony.Sms.Intents.SECRET_CODE_ACTION
import android.telephony.PhoneNumberUtils
import android.telephony.TelephonyManager
import android.text.Editable
import android.util.TypedValue
import android.view.KeyEvent
import android.view.MotionEvent
Expand All @@ -28,7 +29,10 @@ import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.adapters.ContactsAdapter
import com.simplemobiletools.dialer.databinding.ActivityDialpadBinding
import com.simplemobiletools.dialer.extensions.*
import com.simplemobiletools.dialer.fragments.hidePrivateContacts
import com.simplemobiletools.dialer.helpers.DIALPAD_TONE_LENGTH_MS
import com.simplemobiletools.dialer.helpers.MIN_RECENTS_THRESHOLD
import com.simplemobiletools.dialer.helpers.RecentsHelper
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
import com.simplemobiletools.dialer.models.SpeedDial
import java.util.*
Expand Down Expand Up @@ -346,6 +350,32 @@ class DialpadActivity : SimpleActivity() {
startCallIntent(number)
}
}
} else {
setLastDialedNumber()
}
}

private fun setLastDialedNumber() {

Ashutoshgupta22 marked this conversation as resolved.
Show resolved Hide resolved
var lastDialed: String?

val privateCursor = this.getMyContactsCursor(false, true)
val groupSubsequentCalls = this.config.groupSubsequentCalls
val querySize = MIN_RECENTS_THRESHOLD
RecentsHelper(this).getRecentCalls(groupSubsequentCalls, querySize) { recents ->

Ashutoshgupta22 marked this conversation as resolved.
Show resolved Hide resolved
val privateContacts = MyContactsContentProvider.getContacts(this, privateCursor)

lastDialed = recents
.hidePrivateContacts(
privateContacts,
SMT_PRIVATE in this.baseConfig.ignoredContactSources
).firstOrNull()?.phoneNumber

lastDialed?.let {
binding.dialpadInput.text = Editable.Factory.getInstance()
.newEditable(it)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.simplemobiletools.dialer.fragments

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ContactsHelper
Expand Down Expand Up @@ -176,7 +177,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
}

// hide private contacts from recent calls
private fun List<RecentCall>.hidePrivateContacts(privateContacts: List<Contact>, shouldHide: Boolean): List<RecentCall> {
fun List<RecentCall>.hidePrivateContacts(privateContacts: List<Contact>, shouldHide: Boolean): List<RecentCall> {
return if (shouldHide) {
filterNot { recent ->
val privateNumbers = privateContacts.flatMap { it.phoneNumbers }.map { it.value }
Expand Down