implement Recent Call removing

This commit is contained in:
tibbi
2018-08-04 18:24:26 +02:00
parent 4743fcd730
commit 46580c3620
4 changed files with 63 additions and 6 deletions

View File

@ -1323,7 +1323,7 @@ class ContactsHelper(val activity: Activity) {
return@Thread
}
val uri = android.provider.CallLog.Calls.CONTENT_URI
val uri = CallLog.Calls.CONTENT_URI
val projection = arrayOf(
CallLog.Calls._ID,
CallLog.Calls.NUMBER,
@ -1371,4 +1371,29 @@ class ContactsHelper(val activity: Activity) {
callback(calls)
}.start()
}
fun removeRecentCalls(ids: ArrayList<Int>) {
Thread {
try {
val operations = ArrayList<ContentProviderOperation>()
val selection = "${CallLog.Calls._ID} = ?"
ids.forEach {
ContentProviderOperation.newDelete(CallLog.Calls.CONTENT_URI).apply {
val selectionArgs = arrayOf(it.toString())
withSelection(selection, selectionArgs)
operations.add(build())
}
if (operations.size % BATCH_SIZE == 0) {
activity.contentResolver.applyBatch(CallLog.AUTHORITY, operations)
operations.clear()
}
}
activity.contentResolver.applyBatch(CallLog.AUTHORITY, operations)
} catch (e: Exception) {
activity.showErrorToast(e)
}
}.start()
}
}