mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-04-02 20:41:16 +02:00
make sure the app has Write Call Log permission at clearing call log
This commit is contained in:
parent
cc274b35e5
commit
eda7bac49a
@ -56,6 +56,6 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.32.19'
|
||||
implementation 'com.simplemobiletools:commons:5.32.23'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
private fun clearCallHistory() {
|
||||
ConfirmationDialog(this, "", R.string.clear_history_confirmation) {
|
||||
RecentsHelper(this).removeAllRecentCalls {
|
||||
RecentsHelper(this).removeAllRecentCalls(this) {
|
||||
runOnUiThread {
|
||||
recents_fragment?.refreshItems()
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import android.provider.CallLog.Calls
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
||||
import com.simplemobiletools.dialer.models.RecentCall
|
||||
|
||||
@ -121,11 +121,15 @@ class RecentsHelper(private val context: Context) {
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
fun removeAllRecentCalls(callback: () -> Unit) {
|
||||
ensureBackgroundThread {
|
||||
val uri = Calls.CONTENT_URI
|
||||
context.contentResolver.delete(uri, null, null)
|
||||
callback()
|
||||
fun removeAllRecentCalls(activity: SimpleActivity, callback: () -> Unit) {
|
||||
activity.handlePermission(PERMISSION_WRITE_CALL_LOG) {
|
||||
if (it) {
|
||||
ensureBackgroundThread {
|
||||
val uri = Calls.CONTENT_URI
|
||||
context.contentResolver.delete(uri, null, null)
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user