mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
implement Recent Call removing
This commit is contained in:
@ -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()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user