do not show blocked numbers at the Recents tab

This commit is contained in:
tibbi 2020-05-23 17:47:49 +02:00
parent 76ecb2ec1e
commit b4b376cbfc
3 changed files with 6 additions and 3 deletions
app
build.gradle
src/main
kotlin/com/simplemobiletools/dialer/helpers
res/menu

@ -56,6 +56,6 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.28.17'
implementation 'com.simplemobiletools:commons:5.28.19'
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
}

@ -7,6 +7,7 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALL_LOG
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.getQuestionMarks
import com.simplemobiletools.dialer.extensions.config
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
import com.simplemobiletools.dialer.models.RecentCall
@ -14,7 +15,8 @@ class RecentsHelper(private val context: Context) {
@SuppressLint("MissingPermission")
fun getRecentCalls(callback: (ArrayList<RecentCall>) -> Unit) {
ensureBackgroundThread {
val recentCalls = ArrayList<RecentCall>()
var recentCalls = ArrayList<RecentCall>()
val blockedNumbers = context.getBlockedNumbers()
if (!context.hasPermission(PERMISSION_READ_CALL_LOG)) {
callback(recentCalls)
return@ensureBackgroundThread
@ -63,6 +65,7 @@ class RecentsHelper(private val context: Context) {
previousRecentCallFrom = "$number$name"
}
recentCalls = recentCalls.filter { !context.isNumberBlocked(it.phoneNumber) }.toMutableList() as ArrayList<RecentCall>
callback(recentCalls)
}
}

@ -16,6 +16,6 @@
<item
android:id="@+id/cab_remove"
android:icon="@drawable/ic_delete_vector"
android:title="@string/remove"
android:title="@string/delete"
app:showAsAction="ifRoom" />
</menu>